5

I was reading about passwordless authentication with ssh. So I made a key and published it to my Ubuntu server, and it worked well.

Then decided to lock my password with passwd -l lucas, and I was not longer able to use sudo. I was thinking that sudo would also be without a password.

My question now is: how can I regain the ability to use sudo?

3

2 Answers 2

3

After running passwd -l on a user, that user can't set their password (until after it's set back to something usable).

Since you cannot use sudo, you'll need to reset your user account password, the same way as if you'd just forgotten what it was:

Then you can use sudo again, and you can set PasswordAuthentication no as explained in steeldriver's answer.

1
  • Thank you! it's setup now. I added in root mode NOPASSWD to sudo for my main user Aug 22, 2014 at 19:57
2

You will likely need to login to a root shell via the recovery console in order to re-enable your account password. After that, you can disable password login for ssh specifically by setting

PasswordAuthentication no

in the sshd_config file, and leave the account password enabled for local access (including running sudo once you have logged in via SSH using keys)

You must log in to answer this question.

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