* [PATCH cluster 0/2] Refine setup_sshd_config()
@ 2026-11-18 14:28 Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 1/2] cluster: setup: keep file permissions for sshd config Shannon Sterz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-11-18 14:28 UTC (permalink / raw)
To: pve-devel
these patches allow users to set their own permissions on the sshd
config and should pick up more cases in which a user may have adjusted
`PermitRootLogin` in a way that could break functionality.
Shannon Sterz (2):
cluster: setup: keep file permissions for sshd config
cluster: setup: match PermitRootLogin option more precisely
src/PVE/Cluster/Setup.pm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH cluster 1/2] cluster: setup: keep file permissions for sshd config
2026-11-18 14:28 [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
@ 2026-11-18 14:28 ` Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 2/2] cluster: setup: match PermitRootLogin option more precisely Shannon Sterz
2026-11-19 11:25 ` Superseded: Re: [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
2 siblings, 0 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-11-18 14:28 UTC (permalink / raw)
To: pve-devel
certain users may want to set stricter permissions than
`file_set_contents`'s 0644 default permissions. this change keeps
those permissions when modifying the file.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/PVE/Cluster/Setup.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/PVE/Cluster/Setup.pm b/src/PVE/Cluster/Setup.pm
index 8a398d3..2550f70 100644
--- a/src/PVE/Cluster/Setup.pm
+++ b/src/PVE/Cluster/Setup.pm
@@ -157,7 +157,8 @@ sub setup_sshd_config {
$conf .= "\nPermitRootLogin yes\n";
}
- PVE::Tools::file_set_contents($ssh_system_server_config, $conf);
+ my $mode = (stat($ssh_system_server_config))[2] & 07777;
+ PVE::Tools::file_set_contents($ssh_system_server_config, $conf, $mode);
PVE::Tools::run_command(['systemctl', 'reload-or-restart', 'sshd']);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH cluster 2/2] cluster: setup: match PermitRootLogin option more precisely
2026-11-18 14:28 [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 1/2] cluster: setup: keep file permissions for sshd config Shannon Sterz
@ 2026-11-18 14:28 ` Shannon Sterz
2026-11-19 11:25 ` Superseded: Re: [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
2 siblings, 0 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-11-18 14:28 UTC (permalink / raw)
To: pve-devel
`setup_sshd_config()` tries to find a line relating to the setting
`PermitRootLogin` in the sshd config. the previous regex did not match
certain cases (e.g., " PermitRootLogin yes"; " # PermitRootLogin no").
if nothing is matched the function adds a "PermitRootLogin yes" line
to the end of the file.
this would allow for cases where " PermitRootLogin no" and
"PermitRootLogin yes" are present in the same file. sshd applies the
first option it finds, so root login would be disabled. without
"PermitRootLogin yes" set any cluster join and certain functionality,
such as zfs replication, would break.
adjust the regex so that the "PermitRootLogin" option is picked up in
those cases too. also match case insensitively and allow statements
such as `permitrootlogin=yes` as OpenSSH also accepts them.
further, the early return is extended to only care about the first
occurrence of the `PermitRootLogin` option as that's the one OpenSSH
cares about.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
Notes:
note that by default on our installs the setting is "PermitRootLogin
yes". so this scenario could only happen if a user manually adjusts
it. however, setting "PermitRootLogin no" is often recommended so
someone accidentally adding a space infront of that line is not
impossible.
src/PVE/Cluster/Setup.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Cluster/Setup.pm b/src/PVE/Cluster/Setup.pm
index 2550f70..b446059 100644
--- a/src/PVE/Cluster/Setup.pm
+++ b/src/PVE/Cluster/Setup.pm
@@ -150,9 +150,9 @@ sub setup_sshd_config {
my $conf = PVE::Tools::file_get_contents($ssh_system_server_config);
- return if $conf =~ m/^PermitRootLogin\s+yes\s*$/m;
+ return if $conf =~ m/^\h*PermitRootLogin(?:\h*=\h*|\h+)(\S+)/mi && lc($1) eq 'yes';
- if ($conf !~ s/^#?PermitRootLogin.*$/PermitRootLogin yes/m) {
+ if ($conf !~ s/^(?:\h*#)*\h*PermitRootLogin.*$/PermitRootLogin yes/mi) {
chomp $conf;
$conf .= "\nPermitRootLogin yes\n";
}
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Superseded: Re: [PATCH cluster 0/2] Refine setup_sshd_config()
2026-11-18 14:28 [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 1/2] cluster: setup: keep file permissions for sshd config Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 2/2] cluster: setup: match PermitRootLogin option more precisely Shannon Sterz
@ 2026-11-19 11:25 ` Shannon Sterz
2 siblings, 0 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-11-19 11:25 UTC (permalink / raw)
To: Shannon Sterz, pve-devel
Superseded-by: https://lore.proxmox.com/pve-devel/20261119112318.118471-1-s.sterz@proxmox.com/T/#t
On Wed Nov 18, 2026 at 3:28 PM CET, Shannon Sterz wrote:
> these patches allow users to set their own permissions on the sshd
> config and should pick up more cases in which a user may have adjusted
> `PermitRootLogin` in a way that could break functionality.
>
> Shannon Sterz (2):
> cluster: setup: keep file permissions for sshd config
> cluster: setup: match PermitRootLogin option more precisely
>
> src/PVE/Cluster/Setup.pm | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> --
> 2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-19 11:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 14:28 [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 1/2] cluster: setup: keep file permissions for sshd config Shannon Sterz
2026-11-18 14:28 ` [PATCH cluster 2/2] cluster: setup: match PermitRootLogin option more precisely Shannon Sterz
2026-11-19 11:25 ` Superseded: Re: [PATCH cluster 0/2] Refine setup_sshd_config() Shannon Sterz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.