Skip to content

Commit 74aba22

Browse files
authored
security: disable password auth for root and ubuntu (#2161)
* security: remove passwords for root and ubuntu This prevents the users from being logged into except by SSH public key authentication. * fix: ensure Password and Challenge Response auth for SSH is disabled
1 parent 9b79a56 commit 74aba22

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

ebssurrogate/scripts/qemu-bootstrap-nix.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ function clean_system {
156156
rm -rf /root/.vpython*
157157
rm -rf /root/go
158158
rm -rf /mnt/usr/share/doc
159+
160+
# remove passwords in user-data-cloudimg.img (required for Packer login)
161+
usermod -p '*' ubuntu
162+
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; }
159172
}
160173

161174
install_nix

0 commit comments

Comments
 (0)