Leaving root access enabled by default can pose significant security risks. It’s much more secure to disable root access and instead use sudo within another SSH account to execute root-level commands. Follow these simple steps to disable root SSH access on your Linux server.
Use your terminal client to log into your server with your SSH credentials.
Open the /etc/ssh/sshd_config
file using a text editor:
sudo nano /etc/ssh/sshd_config
Scroll down or search to find the line #PermitRootLogin
.
Remove the #
symbol, change the value to no
, then save and exit the file.
Restart the SSH service to apply the changes:
sudo service sshd restart
This will disable root SSH access, improving the security of your server.