Skip to content

Commit

Permalink
fix: sshd config
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito committed Sep 4, 2024
1 parent ac73b70 commit e5cef90
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion util/cloudinit/cloudconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e5cef90

Please # to comment.