Checks / SSH

SSH accepts passwords

Check
ssh.password_auth
Severity
medium
Runs
on the server, in the daily run of the agent
Looks at
PasswordAuthentication is yes, or KbdInteractiveAuthentication is yes with UsePAM yes
Updated 26 Nov 2026

What the check looks at

The effective sshd configuration (sshd -T, with all included files). The check fails when PasswordAuthentication is yes, or when KbdInteractiveAuthentication is yes together with UsePAM yes: keyboard-interactive login then asks for the same password through PAM. It passes when AuthenticationMethods lists neither password nor keyboard-interactive, and it warns when a Match block turns passwords on.

Risk

Bots send password guesses to every public SSH server. A strong, unique password holds against guessing, but passwords 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 guesses only fill the log.

How to fix it

Check first that you can log in with a key and run sudo, and keep the current session open; the key-only login guide has the steps.

Then add a drop-in file. sshd keeps the first value it reads for each setting and reads the files in /etc/ssh/sshd_config.d/ in alphabetical order, so the name starts with a low number. 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 distribution:

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

Cloud images can have a file such as /etc/ssh/sshd_config.d/50-cloud-init.conf with PasswordAuthentication yes. The 10- file wins; delete that line anyway.

RHEL, Rocky Linux and AlmaLinux

sudo systemctl reload sshd

On RHEL 8 (OpenSSH 8.0), add ChallengeResponseAuthentication no to the file too. Before OpenSSH 8.7 it was a separate setting, not an alias of KbdInteractiveAuthentication.

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).

With Match blocks, test the values for one connection, for example sudo sshd -T -C user=deploy,host=example.org,addr=203.0.113.5.

When a warning is fine

A second factor through PAM, such as a TOTP module, keeps KbdInteractiveAuthentication yes with AuthenticationMethods publickey,keyboard-interactive. The prompt then comes only after a valid key; accept the result on the dashboard. Password logins allowed only from a management network in a Match Address block are another case; check them with sshd -T -C.

An accepted result stays out of the digest and the counts until it changes.

Sources

  • sshd_config(5) (PasswordAuthentication, KbdInteractiveAuthentication, AuthenticationMethods, Match; the first value wins)
  • sshd(8) (-T and -C)
  • OpenSSH 8.7 release notes. ChallengeResponseAuthentication becomes an alias; before, the two were "somewhat but not entirely equivalent".