Broken sudo on amazon web services ec2 linux centOS

Solution 1:

I messed up an instance in the exact same way once and I was able to recover it by mounting its EBS volume from a separate working instance. There are many steps involved:

  • From the EC2 Management Console, stop your EC2 instance
  • Go to the Volumes screen and detach the problematic EBS volume from the instance
  • Fire a new, fresh micro instance using a stock Linux AMI with default options (unless you already have another working instance)
  • Once the new instance is running, attach the problematic EBS volume to it
  • Then mount it

Once mounted as a directory, you should be able to access the filesystem of the problematic volume from the new instance and fix the sudoers file. Then simply unmount and detach the volume and reattach it to the other instance.