What are you looking for?
Categories
< All Topics
Print

HOW TO DISABLE ROOT LOGIN

For your server security you should disable root login to prevent hacking attempts. After disabling root login, when you need to do root task use ‘sudo’ or ‘su-  command with your root password to get root privilege.

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

nano /etc/ssh/sshd_config

then find

#PermitRootLogin no
Remove the # from that line to activate this option, then press ctrl+x then y to save your edit.

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 then restart SSHD.

sudo /etc/init.d/sshd restart

You are all done.

Table of Contents