From 667c265f17f36983a110444217e2ae23092a113f Mon Sep 17 00:00:00 2001 From: Froz Date: Wed, 24 Jan 2024 10:43:24 -0800 Subject: [PATCH] Update part-1-ubuntu-initial-setup.sh --- initial ubuntu setup/part-1-ubuntu-initial-setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/initial ubuntu setup/part-1-ubuntu-initial-setup.sh b/initial ubuntu setup/part-1-ubuntu-initial-setup.sh index eb8835c..7bf798b 100644 --- a/initial ubuntu setup/part-1-ubuntu-initial-setup.sh +++ b/initial ubuntu setup/part-1-ubuntu-initial-setup.sh @@ -70,6 +70,10 @@ chown --recursive "${USERNAME}":"${USERNAME}" "${home_directory}/.ssh" # Disable root SSH login with password. 2nd line disables PasswordAuthentication for sudo user sed --in-place 's/^PermitRootLogin.*/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config sed --in-place 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config + +# It seems in newer Ubuntu versions like 24.04 the config is stored in /etc/ssh/sshd_config.d/50-cloud-init.conf so this line below turns off pw auth +# in the newer Ubuntu. Credits to oitconz for finding this at https://github.com/StarWhiz/docker_deployment_notes/issues/5#issue-2087522025 +sed --in-place 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config.d/50-cloud-init.conf if sshd -t -q; then systemctl restart sshd fi