Lost sudo/su on Amazon EC2 instance

Posted by barrycarter on Super User See other posts from Super User or by barrycarter
Published on 2011-10-13T16:27:27Z Indexed on 2011/11/11 18:00 UTC
Read the original article Hit count: 245

Filed under:

I have an Amazon EC2 instance. I can login just fine, but neither "su" nor "sudo" work now (they worked fine previously):

  • "su" requests a password, but I login using ssh keys, and I don't think the root user even has a password.

  • "sudo <anything>" does this:


sudo: /etc/sudoers is owned by uid 222, should be 0 
sudo: no valid sudoers sources found, quitting 

I probably did "chown ec2-user /etc/sudoers" (or, more likely "chown -R ec2-user /etc" because I was sick of rsync failing), so this is my fault.

How do I recover? I stopped the instance and tried the "View/Change User Data" option on the AWS EC2 console, but this didn't help.

EDIT: I realize I could kill this instance and create a new one, but was hoping to avoid something that extreme.

© Super User or respective owner

Related posts about aws