7

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?

10

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

3

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

PasswordAuthentication no
  • I've done this, and root user can get in without password, but another sudo/wheel user cannot. Despite putting a key in the command, that user still needs a password. Can I disable a password and enable ONLY key login for that other sudo/wheel user too? – PKHunter Aug 14 '17 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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