Rainhost.net    

Disable Root Login

Jul 17, 2015
0

For your server security you can disable root login to prevent any hacking attempt. When you need to do admin task just use ‘sudo’ or ‘su- ┬ácommands to get root privilege.

 

To disable root login, open the main ssh configuration file /etc/ssh/sshd_config. You can do it by ‘vi’ command or use sftp client to edit that file.

vi /etc/ssh/sshd_config

then find

#PermitRootLogin no
Remove the # from that line to activate this option

Now restart SSHD

/etc/init.d/sshd restart

If you get Access denied error

Use su – command and enter your root password. You can also try

sudo /etc/init.d/sshd restart

You are done. Now if you want enable back to Root login just open again that editor and comment out ‘PermitRootLogin no’ by adding # before this line. and restart SSHD

sudo /etc/init.d/sshd restart

You are all done.