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 Find Largest Files & Directories in Linux
How to Disable Commands in Linux
Linux History: Show Commands with Date & Time
How to Flush DNS Cache in Windows, Linux & Mac
How to Recover Deleted Files in Linux
How to Sort Files by Size in Linux
How to Stop/Prevent SSH Brute Force Attacks
How to Change Default Home Directory of User in Linux

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