DIRNAME_SSH=.ssh
PATH_ROOT_SSH="${HOME}/${DIRNAME_SSH}"
PATH_USER_SSH="${PATH_HOME_USER}/${DIRNAME_SSH}"
-PATH_SSHD_DROPIN=/etc/ssh/sshd_config.d/60-no-root-login.conf
+PATH_SSHD_DROPIN=/etc/ssh/sshd_config.d/60-ssh-hardening.conf
start_root server
mv "${PATH_ROOT_SSH}" "${PATH_HOME_USER}"
chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_SSH}"
-# Removing root's key isn't enough on its own to guarantee no direct root
-# SSH login: whether that suffices depends on the image's own
-# PermitRootLogin setting, which a root password (set below) could
-# otherwise still satisfy. Pin it explicitly instead of relying on that.
-msg 'Disabling direct root SSH login …'
-printf 'PermitRootLogin no\n' >| "${PATH_SSHD_DROPIN}"
+msg 'Hardening SSH login: no root login, no password auth …'
+printf 'PermitRootLogin no\nPasswordAuthentication no\n' >| "${PATH_SSHD_DROPIN}"
systemctl reload ssh
msg 'Setting up root password-login …'