Most Linux distributions allow the root user to connect in via SSH, however if you try to connect into Ubuntu as root after a default install, you will find that you wont be able to get in. While it may look like the root account is not permitted to login, it is just because that the root account doesn’t have a password set. If you end up setting a password on the root account for some reason, you will be able to SSH in as root.
It is recommended that root logins are never used, and you should use either su or sudo to elevate the permissions of a normal user account. As such, the best option is to disable root logins in the SSH server configuration file.
Open the /etc/ssh/sshd_config file in your editor of choice (nano in this example):
$ sudo nano /etc/ssh/sshd_config
There should be a line containing the following:
PermitRootLogin yes
Edit this to read:
PermitRootLogin no
Save the file and exit the editor.
Restart the SSH server:
$ sudo service ssh restart
or
$ sudo /etc/init.d/ssh restart
Root logins over SSH should now be disabled.