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
Related posts:
How to Stop Linux Package Update in Ubuntu
How to Create a Large File in Linux
How to Clear Terminal History in Linux & MacOS
How to Get Filename from Path in Shell Script
What are the Different Shells Available in Linux
How to Get Current Directory of Bash Script
How to Generate & Verify MD5 Hash of File in Linux
How to Change Mac Address in Linux

Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.