Disable Root Login

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.

rainweb has written 24 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>