Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've setup an EC2 instance(PHP, MySQL, phpMyAdmin).

Last night I accidentally execute some command that messed up the permissions.

I was able to login as root before (to ssh using puTTy) but now when I try to login using root I get error which says login as ec2-user instead of root.

Now, If I log in using ec2-user and do sudo. I get error sudo: effective uid is not 0, is sudo installed setuid root?. When I try to login using su or su root. I get Password: and I didn't set any password and default NO PASSWORD is not working, too.

Now, I can't give permissions to sudo for root because sudo is broken and I can't login as root to change permissions because it's asking for password.

How can I overcome this problem?

share|improve this question
    
I'm also having the same problem. –  ArunaFromLK Feb 27 at 10:28
    
I just used the long/only-possible-way, create another instance.Attach faulty volume to the new one and then fix permissions. –  Black0CodeR Mar 18 at 0:57

1 Answer 1

Sounds like the command that was run was a chmod or chown command that modified the OS files ("sudo: effective uid is not 0, is sudo installed setuid root?"). This was probably a recursive (-R) change or a * change.

Therefore fixing everything that was broken is often not worth the effort.

I would:

  1. Take snapshot of each volume associated with your instance.
  2. Create a Volume from each snapshot.
  3. Attach those volumes to a new instance.
  4. Mount them.
  5. Review root's history from the broken server to see what happened.
  6. Backup all your data (web directories, database files, etc.)
  7. Create a new instance to take over for the old broken instance.
  8. Restore to the new instance.
  9. Delete the old instance.
  10. Shutdown the instance that was for mounting the volumes created from the snap shots.
  11. Wait a few days to make sure everything is working.
  12. CAREFULLY, delete volumes and snapshots and instances that are no longer in use.

Also look into Elastic IPs, Chef, SaltStack, and periodic automatic snapshots (careful, this can get expensive if done wrong.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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