I've got a terrible problem on a running webserver. It's a webserver running on CentOS, one of the default Amazon EC2 AMI's (images). I've been able to ssh to the server and do my thing until now. After a 'yum update' a sudo command from the ssh user (the standard user 'ec2-user') needs a password. I can't find a way to perform sudo operations now, and I can't find the default password either. I've never changed the password, so it should be the default value.

Does anyone now the default password, or a solution? SSH'ing as root does not work.


You'll need to do an offline recovery. The steps are roughly:

  1. Shut down the server.
  2. Start up another temporary instance.
  3. Detach the EBS disk from the original server and attach it to the temporary server.
  4. Mount the filesystem.
  5. Edit /etc/shadow and copy/paste a known password hash into the ec2-user's entry.
  6. Unmount and detach from temporary server.
  7. Re-attach EBS volume to original instance.
  8. Start up original instance.

Once you complete those steps, you should be able to sudo using the password that corresponds with the password hash you pasted in.

  • Thanks! I'll give that a try as soon as I'm on it again :) I'll keep you posted. – Keugels Jun 10 '15 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.