From e5cef90822e61b8a2ec637b81bc2acf082290128 Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Wed, 4 Sep 2024 19:27:20 +0800 Subject: [PATCH] fix: sshd config --- util/cloudinit/cloudconfig.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/cloudinit/cloudconfig.go b/util/cloudinit/cloudconfig.go index 36f3b77..c144074 100644 --- a/util/cloudinit/cloudconfig.go +++ b/util/cloudinit/cloudconfig.go @@ -236,12 +236,15 @@ func (conf *SCloudConfig) UserDataScript() string { if conf.DisableRoot == 0 { shells = append(shells, `sed -i "s/.*PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config`) + shells = append(shells, `sed -i "s/.*PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config.d/*.conf`) } if conf.SshPwauth == SSH_PASSWORD_AUTH_ON { shells = append(shells, `sed -i 's/.*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config`) + shells = append(shells, `sed -i 's/.*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config.d/*.conf`) } if conf.DisableRoot == 0 || conf.SshPwauth == SSH_PASSWORD_AUTH_ON { - shells = append(shells, `systemctl restart sshd`) + // ubuntu24.04 sshd -> ssh + shells = append(shells, `systemctl restart sshd ssh`) } for _, pkg := range conf.Packages {