Disabling root access via SSH is a good security measure for any public-facing web server. This is because some hackers targeting linux servers know that there’s always a root user and often try to gain access to a server using brute force for that user. So here’s how to disable root login via SSH on ubuntu.
First, make sure there’s at least one other user with sudo privilege. If none exists, create one with the command:
sudo adduser <someuser> sudo adduser <someuser> sudo
Next, edit /etc/ssh/sshd_config using your favourite editor.
Find the line:
and change it to
Save and close the file.
Restart SSH daemon using the command
sudo service ssh restart