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.
- Log in to your server:
Use your terminal client to log into your server with your SSH credentials. - Edit the SSH Configuration File:
Open the /etc/ssh/sshd_config file using a text editor:sudo nano /etc/ssh/sshd_config - Find the PermitRootLogin Directive:
Scroll down or search to find the line#PermitRootLogin. - Disable Root Login:
Remove the#symbol, change the value tono, then save and exit the file. - Restart the SSH Service:
Restart the SSH service to apply the changes:sudo service sshd restart
This will disable root SSH access, improving the security of your server.