disable ssh root login in linux

How to Disable SSH Root Login in Linux

By default, every Linux system has a root user that has access to all commands, files & folders. If someone gets access to root user, then they can misuse your system. So it is important to disable SSH root login in Linux. In this article, we will look at how to do this.


How to Disable SSH Root Login in Linux

Here are the steps to disable SSH root login in Linux.


1. Open SSH configuration

Open terminal and run the following command to open SSH configuration file.

$ sudo vi /etc/ssh/sshd_config


2. Disable SSH Root Login

Look for the following line

PermitRootLogin yes

Replace it with the following line

PermitRootLogin no

Save and close the file.


3. Restart SSH server

Restart SSH Service to apply changes.

Ubuntu/Debian

$ sudo service ssh restart

Redhat/CentOS/Fedora

$ sudo systemctl restart sshd

That’s it. Now root user will not be able to log into SSH.

Also read:

How to Open, Extract RAR File in Linux
How to Stop Linux Package from Update
How to Generate PGP Key in Linux
How to Log Shell Script Output to File
Find PID of Process Running on Port

Leave a Reply

Your email address will not be published.