Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com Nov 20 '10 at 22:54

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

4 Answers 4

up vote 17 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
2  
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

 
discard

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.