Skip to content

5.2.7 Ensure SSH root login is disabled

Audit#

Run the following command:

# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname) /etc/hosts | awk '{print $1}')" | grep permitrootlogin

Verify the output matches:

permitrootlogin no

Run the following command:

# grep -Ei '^\s*PermitRootLogin\s+no' /etc/ssh/sshd_config

Verify the output matches:

PermitRootLogin no

Remediation#

Edit the /etc/ssh/sshd_config file to set the parameter as follows:

PermitRootLogin no

Default Value:

PermitRootLogin without-password