By default SSH comes configured in a way that disables root user logins
Note: On Ubuntu, by default installation comes with unset root password, To set root password, please read this article.
Enable Root Login over SSH
1. To disable root login, edit file /etc/ssh/sshd_config:
[email@example.com ~] sudo vi /etc/ssh/sshd_config
2. Add a line in the Authentication section of the file that says PermitRootLogin yes. This line may already exist and be commented out with a “#”. In this case, remove the “#”.
Save the updated of config file
3. Restart the SSH service
# Restart ssh service on Redhat/CentOS [firstname.lastname@example.org ~] sudo systemctl restart sshd # Restart ssh service on Ubuntu/Debian/Linuxmint [email@example.com ~] sudo /etc/init.d/ssh restart
You can now connect to the server as root over SSH.
Limit SSH User Logins
Edit file /etc/ssh/sshd_config, add an AllowUsers line at the bottom of the file with a space separated by list of usernames.
Replace <user> with your user. After restart ssh service