To disable root login for SSH, you need to edit the configuration file /etc/ssh/sshd_config.
nano /etc/ssh/sshd_config
Find the following line and remove the # sign.
#PermitRootLogin no
PermitRootLogin no
All that remains is to restart the SSH service.
/etc/init.d/ssh restart
On Debian and Ubuntu the service is called ssh, on CentOS sshd (/etc/init.d/sshd restart).
Now when we try to log in with Root access, we get a "Permission denied" error message.
Now after logging in as a classic user, you need to use the su command to switch to the Root user.