SSH accepts passwords
- Check
ssh.password_auth- Severity
- medium
- Runs
- on the server, in the daily run of the agent
- Looks at
- PasswordAuthentication or KbdInteractiveAuthentication is yes
What the check looks at
The agent reads the effective sshd configuration (sshd -T, with all included files) and looks at two
settings: PasswordAuthentication and KbdInteractiveAuthentication. The check fails when either is yes.
Both have to be no for passwords to be off, because keyboard-interactive authentication asks for the same
password through PAM.
Why it matters
Every public SSH server gets a steady stream of password guesses from bots. A strong, unique password holds against guessing, but passwords also leak: reused on another site, typed into a phishing page, stored in a script. A key cannot be guessed, and its private part stays on your machine. With passwords off, the guessing traffic only fills the logs.
How to fix it
First make sure you can log in with a key and that the user can run sudo; the
key-only login guide walks through it without locking yourself out. Keep the
current session open.
Then add a drop-in file. sshd keeps the first value it reads for each setting, and the files in
/etc/ssh/sshd_config.d/ are read in alphabetical order, so the low number matters. On RHEL 8, Rocky Linux 8
and AlmaLinux 8, sshd_config does not read that directory (check with
grep -i '^include' /etc/ssh/sshd_config). Add the Include line at the top there first:
sudo mkdir -p /etc/ssh/sshd_config.d
sudo sed -i '1i Include /etc/ssh/sshd_config.d/*.conf' /etc/ssh/sshd_config
Then, on every system:
sudo tee /etc/ssh/sshd_config.d/10-passwords.conf >/dev/null <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
EOF
sudo sshd -t
Reload sshd:
Debian and Ubuntu
sudo systemctl reload ssh
On cloud images, look for a file such as /etc/ssh/sshd_config.d/50-cloud-init.conf that sets
PasswordAuthentication yes. Your 10- file wins over it, but it is clearer to delete that line.
RHEL, Rocky Linux and AlmaLinux
sudo systemctl reload sshd
On RHEL 8, also add ChallengeResponseAuthentication no to the file; OpenSSH releases before 8.7 have both
names.
Alpine
sudo rc-service sshd reload
How to check the fix
sudo sshd -T | grep -E '^(passwordauthentication|kbdinteractiveauthentication) '
Both lines must end in no. From another machine:
ssh -o PubkeyAuthentication=no user@server
The answer must be Permission denied (publickey).
If you use Match blocks, test the values for a specific connection, for example
sudo sshd -T -C user=deploy,host=example.org,addr=203.0.113.5.
When a warning is fine
Some setups need a second factor through PAM (for example a TOTP module) and keep KbdInteractiveAuthentication yes together with AuthenticationMethods publickey,keyboard-interactive. Then the password prompt only comes
after a valid key, and you can accept the result on the dashboard. Password logins that are only allowed from a management
network through a Match Address block are another case; check them with sshd -T -C.
An accepted result is left out of the digest and the counts until it changes; then it shows again.
Sources
- sshd_config(5) —
PasswordAuthentication,KbdInteractiveAuthentication,AuthenticationMethods,Match, first obtained value wins - sshd(8) —
-Tand-Cfor the effective configuration - OpenSSH 8.7 release notes —
ChallengeResponseAuthenticationas the deprecated alias