How to disable SSH login for the root user?

This forum is for the posting and reading of tutorials.
Post Reply
User avatar
kheny22
Apprentice
Posts: 8
Joined: Fri May 01, 2020 8:37 pm

How to disable SSH login for the root user?

Post by kheny22 »

To disable root login, open the main ssh configuration file /etc/ssh/sshd_config with your choice of editor.

Code: Select all

#vi /etc/ssh/sshd_config
Search for the following line in the file.

Code: Select all

#PermitRootLogin no
Remove the ‘#‘ from the beginning of the line. Make the line look like similar to this.
PermitRootLogin no

Next, we need to restart the SSH daemon service.

Code: Select all

# /etc/init.d/sshd restart
OR
#service sshd restart
Now try to login with root user, you will get “Access Denied” error.

Post Reply