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?

Justin
  • 5,328
  • 19
  • 64
  • 84

2 Answers2

10

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

Alex
  • 7,939
  • 6
  • 38
  • 52
3

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

PasswordAuthentication no
anastrophe
  • 5,488
  • 2
  • 16
  • 16
  • 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