One time I accidentally messed with the /etc/passwd
and locked myself out of being able to SSH into the machine. Since this is a remote machine in AWS I had no way of doing what I'd normally do. Which is attaching a keyboard and monitor and fixing this manually.
To fix, use the AWS EC2 Management page to:
- spin up a new instance of vanilla ubuntu EC2 (let's call it David)
- shutdown the locked machine (let's call it Goliath)
- unmount Goliath's volume
- attach the volume to David
Then follow this guide: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html