2

is it possible to have a user account in Linux that can only login through its SSH public key?

I thought to simply do sudo passwd -l myuser and lock the account (so I don't need to generate some random and secure password) and allow to login only through SSH public key. Unfortunately this does not work (log says: User myuser not allowed because account is locked).

Thanks

1
  • 1
    If the password is unknown and you only allow public key auth, for all intents and purposes, you've created an account that can only log in with keys.
    – NickW
    Apr 8, 2014 at 13:36

1 Answer 1

0

Just generate a random string and pass it to the useradd command. If nothing else, useradd -p '*NP*' <userid> will do the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .