Knowledge Base

How to Disable Root Access in Linux

Linux logo

This article will show you how to disable root access in Linux.

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.


1. Log in to your server

Use your terminal client to log in to your server with your SSH credentials.

2. Edit the SSH Configuration File

Open the /etc/ssh/sshd_config file using a text editor:

sudo nano /etc/ssh/sshd_config

3. Find the PermitRootLogin Directive

Scroll down or search to find the line #PermitRootLogin.

4. Disable Root Login

Remove the # symbol, change the value to no, then save and exit the file.

5. 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.


Next: How to Change the SSH Port in Linux moves SSH off the port that gets scanned most.

Please rate this article to help us improve our Knowledge Base.

0 0