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

How can I create a user on CentOS 5.6, which cannot login with a password. I.E. they can only login and SSH using public key authentication.

 useradd myuser -d /their-home-dir

Will that do it, without calling passwd?

share|improve this question
up vote 10 down vote accepted

Yes, that will do it but you should add some keys to ~/.ssh/authorized_keys of course.

share|improve this answer

If you want to enforce only pubkey auth, then you need to modify your /etc/ssh/sshd_config , and set

PasswordAuthentication no
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.