I managed to save my sudoers file with a syntax error so now I can't do sudo -i any more on my EC2 instance.
This effectively locks me out of root account since the only way to get root access on EC2 is via sudo.
How can I fix this?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
You need to spawn a new EC2 instance (minimal size will do), and make sure you can log in via SSH and sudo into the new instance.
After that, shut down the current instance and detach virtual disk.
Shut down also the newly spawned EC2 instance, and attach the virtual disk as secondary disk on that instance, and boot it.
After the boot, mount the root partition of old drive, fix sudo file, shut down, detach disk, attach it back to original VM, and boot it.
It's not a simple procedure, but I did it couple of times.