Even though the communications channel may be encrypted, an additional layer of security is gained by extending the policy of not logging directly on as root. In addition, logging in with a user-specific account provides individual accountability of actions performed on the system and helps to minimize direct attack attempts on root's password.
OpenSSH uses the first occurrence of a keyword it sees, and drop-in files are read in lexicographical order at the start of the configuration. Red Hat recommends using drop-in files rather than changing base configuration files.
Check
Verify RHEL 10 remote access using SSH prevents users from logging on directly as "root" with the following command:
Verify the runtime setting with the following command:
$ sudo sshd -T | grep -i permitrootlogin permitrootlogin no
If the "PermitRootLogin" keyword is not set to "no" in a drop-in that lexicographically precedes 50-redhat.conf, or if no output is returned, this is a finding.
Fix
Configure RHEL 10 to prevent SSH users from logging on directly as root.
In "/etc/ssh/sshd_config.d", create a drop-in file that will lexicographically precede 50-redhat.conf and add the following line:
PermitRootLogin no
Restart the SSH daemon with the following command for the settings to take effect: