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
The agent reads the effective sshd configuration (sshd -T, with all included files) and fails the check
when PermitEmptyPasswords is yes.
Why it matters
With PermitEmptyPasswords yes and password authentication on, any account whose password field is empty can
log in over SSH by pressing Enter at the password prompt. Bots try common account names (test, guest,
admin, oracle) all day, so such an account is found quickly. The OpenSSH default is no; a yes was set
on purpose, often for a test or a kiosk setup, and then forgotten.
The setting only matters together with an account that has an empty password. The check users.empty_password looks for those accounts.
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 look for accounts with an empty password and give them a password or lock them:
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. The awk command above must print nothing.
When a warning is fine
Never on a server reachable from a network. If a lab machine needs logins without a password, use a key without a passphrase for that account instead.
Sources
- sshd_config(5) —
PermitEmptyPasswords, defaultno - shadow(5) — meaning of an empty password field