Disable direct root login

Bookmark and Share

From ipinfinity.com

Jump to: navigation, search

<digg/>

Allowing the root user to login directly is a major security issue, this guide will show you how to disable it so you can still login as root but just not directly, reducing the security issue.

This will force a hacker to have to guess 2 separate passwords to gain root access. What happens is you'll first need to login as your admin user in SSH, then switch to the super user with the su command to get root. It also forces the use of SSH protocol 2, which is a newer, more secure SSH protocol. Just a couple more ways to help your server stay safe from the bad guys.

  • SSH into your server as 'admin' and gain root access by su
  • Copy and paste this line to edit the file for SSH logins
 /etc/ssh/sshd_config
  • Find the following line:
 Protocol 2, 1
  • Uncomment it, and change it to look like:
 Protocol 2
  • Next, find the following line:
 PermitRootLogin yes
  • Change it to:
 PermitRootLogin no
  • Restart SSH using the following command:
 /etc/rc.d/init.d/sshd restart

Now, no one will be able to login to root with out first loggin in as admin and 'su -' to root, and you will be forcing the use of a more secure protocol. Just make sure you remember both passwords!

Related Links