Control Root Login Using SSH

How to disable password-based root login by replacing it with SSH key-based login.

It is more secure to not permit “Root login” using password. It is a good idea to access root privileges through a local user ID and via su/sudo commands once locally authenticated.

To disable root login using password, set the PermitRootLogin parameter of the sshd_config file to prohibit-password. Once this parameter is set, you will not be able to login using password, but will be able to with ssh keys.

From the sshd_config man page

PermitRootLogin

Specifies whether root can log in using ssh(1). The argument must be yes, prohibit-password, forced-commands-only, or no. The default is prohibit-password.

If this option is set to prohibit-password (or its deprecated alias, without-password), password and keyboard-interactive authentication are disabled for root.

If this option is set to forced-commands-only, root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). All other authentication methods are disabled for root.

If this option is set to no, root is not allowed to log in.