SSH accepts empty passwords
- Check
ssh.empty_passwords- Severity
- critical
- Runs
- on the server, in the daily run of the agent
- Looks at
- PermitEmptyPasswords is yes
What the check looks at
PermitEmptyPasswords in the effective sshd configuration (sshd -T, with all included files). The check
fails when it is yes, also inside a Match block.
Risk
With password logins on, an account with an empty password field logs in when the user presses Enter at the
prompt, and bots try names such as test, guest, admin and oracle on every public SSH server. The
OpenSSH default is no; a yes was set by hand, often for a test or a kiosk, and forgotten. The check
users.empty_password finds the accounts that make the setting a risk.
How to fix it
Remove the line that sets it, or override it with a drop-in file that sshd reads first. On RHEL 8, Rocky
Linux 8 and AlmaLinux 8, sshd_config does not read /etc/ssh/sshd_config.d/; add the Include line at the
top of it first, as the SSH hardening guide shows.
grep -rn PermitEmptyPasswords /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
echo 'PermitEmptyPasswords no' | sudo tee /etc/ssh/sshd_config.d/10-empty-passwords.conf
sudo sshd -t
Then reload sshd. Open sessions stay connected.
Debian and Ubuntu
sudo systemctl reload ssh
RHEL, Rocky Linux and AlmaLinux
sudo systemctl reload sshd
Alpine
sudo rc-service sshd reload
Then list the accounts with an empty password, and give each one a password or lock it:
sudo awk -F: '$2 == "" { print $1 }' /etc/shadow
sudo passwd -l <name>
How to check the fix
sudo sshd -T | grep '^permitemptypasswords'
The output must be permitemptypasswords no, and the awk command above must print nothing.
When a warning is fine
Never on a server that a network can reach. If a lab machine needs logins without a password, give that account a key without a passphrase.
Sources
- sshd_config(5) (
PermitEmptyPasswords, defaultno) - shadow(5). What an empty password field means.