SSH allows root to log in with a password
- Check
ssh.root_login- Severity
- high
- Runs
- on the server, in the daily run of the agent
- Looks at
- PermitRootLogin is yes (prohibit-password and no pass)
What the check looks at
PermitRootLogin in the effective sshd configuration (sshd -T, which includes the files in
/etc/ssh/sshd_config.d/). The check fails when the value is yes and SSH accepts passwords. It warns when
the value is yes and passwords are off, or when a Match block sets yes. The values prohibit-password
(root with a key only, the OpenSSH default), forced-commands-only and no pass.
Risk
Every server has a root account, so bots only have to guess its password; they try root with common and
leaked passwords on every public SSH server. A weak or reused root password then gives them the server. The log
shows a root login, not which person it was.
How to fix it
Create a user with sudo rights and check that you can log in as that user and run sudo (see
key-only login). Then add a drop-in file. Its name starts with a low number
because sshd keeps the first value it reads. 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.
echo 'PermitRootLogin no' | sudo tee /etc/ssh/sshd_config.d/10-root-login.conf
sudo sshd -t
If a backup or deployment system logs in as root with a key, write prohibit-password instead of no.
Then reload sshd. Open sessions stay connected.
Debian and Ubuntu
sudo systemctl reload ssh
RHEL, Rocky Linux and AlmaLinux
sudo systemctl reload sshd
When root login with a password was allowed in the installer, RHEL 9 and later have
/etc/ssh/sshd_config.d/01-permitrootlogin.conf. Delete that file or change its value: sshd reads 01-
before 10-. On RHEL 8 the shipped sshd_config itself sets PermitRootLogin yes; the 10- file, read
through the Include line at the top, wins over it.
Alpine
sudo rc-service sshd reload
If /etc/ssh/sshd_config does not include sshd_config.d, set PermitRootLogin no in
/etc/ssh/sshd_config itself.
How to check the fix
sudo sshd -T | grep '^permitrootlogin'
The output must be permitrootlogin no, or permitrootlogin prohibit-password when root may log in with a
key. Some versions print the older name without-password: Debian 13 with OpenSSH 10.0 does, Alpine 3.24 with
OpenSSH 10.3 does not. From another machine, ssh -o PubkeyAuthentication=no root@<server> must fail.
When a warning is fine
The warning (yes with passwords off) lets root in with a key only, until someone turns passwords back on;
prohibit-password does the same without that risk. There is no good reason for the failed check, even behind
a VPN: a sudo user costs nothing.
Sources
- sshd_config(5) (
PermitRootLogin, defaultprohibit-password; the first value wins) - Red Hat Ceph Storage 8: enabling SSH login as root on RHEL 9
(the drop-in file
01-permitrootlogin.conf)