Skip to content

Commit 2ab30c5

Browse files
committed
fix: ensure Password and Challenge Response auth for SSH is disabled
1 parent f34ee5e commit 2ab30c5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ebssurrogate/scripts/qemu-bootstrap-nix.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ function clean_system {
160160
# remove passwords in user-data-cloudimg.img (required for Packer login)
161161
usermod -p '*' ubuntu
162162
usermod -p '*' root
163+
164+
# Ensure that PasswordAuthentication is off
165+
# From chroot-boostrap-nix.sh
166+
sed -i -E \
167+
-e 's/^#?\s*PasswordAuthentication\s+(yes|no)\s*$/PasswordAuthentication no/g' \
168+
-e 's/^#?\s*ChallengeResponseAuthentication\s+(yes|no)\s*$/ChallengeResponseAuthentication no/g' \
169+
/etc/ssh/sshd_config
170+
grep -qE "^PasswordAuthentication\s+no" /etc/ssh/sshd_config \
171+
|| { echo "ERROR: PasswordAuthentication is not disabled in sshd_config"; exit 1; }
163172
}
164173

165174
install_nix

0 commit comments

Comments
 (0)