Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have about 4 servers and I have always used root to login into SSH. But now I realize that its a security risk so what can I do to not login via root?

share|improve this question

migrated from Nov 20 '10 at 22:54

This question came from our site for professional and enthusiast programmers.

up vote 18 down vote accepted
sudo vi /etc/ssh/sshd_config

Then uncomment or add the following:

PermitRootLogin no

Then restart sshd:

sudo /etc/init.d/sshd restart
share|improve this answer

Look into /etc/ssh/sshd_config and set PermitRootLogin to no. Then restart sshd.

If you want to do administrative tasks through ssh, you can still use su (using roots password) or sudo (that has to be permitted in /etc/sudoers and you don't need the root password) to become root.

If you want your ssh deamon to be even more protected, you can login using public-key authentication. In that case, deactivate logins using passwords by setting PasswordAuthentication to no. Then you'll need keyfiles to login.

share|improve this answer
Public key authentication is highly recommended. – Sean Reifschneider Nov 21 '10 at 3:16
You may want "without-password" or "forced-commands-only" instead of "no". for "PermitRootLogin". These options allow logins only using SSH public keys, or only keys that have a specific command set (for things like remote jobs that need to run as root, say backups). – Sean Reifschneider Nov 21 '10 at 3:18
Thank you. This helped me out. – Chirag Nov 23 '10 at 9:38

Make a separate account and use sudo instead...

share|improve this answer

You can disable root logon in ssh_config in etc directory. If you are asking from client side, login on other username.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.