So, in my attempt to prevent the default
ubuntu user from logging in, and to prevent the default sudo user
me from logging in with a password, and thus enforcing to use the private key, I managed to lock
me out, unable to perform any sudo commands.
Here's what happened.
I ran these commands to prevent
ubuntu from logging in, and to lock
sudo usermod -s /usr/sbin/nologin ubuntu sudo passwd -l me
However, I forgot to add
me ALL=(ALL) NOPASSWD:ALL to the
/etc/sudoers.d/me beforehand. And now, even though I can still login as
me with the private key, I can't execute any
sudo, because it prompts for a password, and the previous password no longer works. I can't login as
ubuntu, the other sudoer, and so I am basically stuck.
me prompts for the current password, which does not exist.
How do I get myself out of this situation? Do I have terminate this box and reinstall? This is not happening on my personal box. This is running on AWS. It's not quite a big of an issue to spin new instances, but I'd like to see if there's an alternative.