Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (11) AWS (5) numerology (5)
Showing posts with label ec2. Show all posts
Showing posts with label ec2. Show all posts

Wednesday, December 12, 2018

ec2-user is not able to do sudo - Linux + AWS


ec2-user is not able to do become root user:

ec2-user is not able to do sudo or ec2-user is not able become root user.

I was getting below error when I logged in as ec2-user with the .ppk file and then I was trying to become root user by using #sudo –i


[ec2-user@cloud_home]# sudo : effective uid is not 0, is sudo installed setuid root ?

While doing initial troubleshooting, we got to know that someone has changed the /usr/bin/sudo file permission accidentally. [But even he was unaware about that]

Answer :


1.      Login to AWS console and stop the instance
2.      Detach the root disk (/dev/sda1)
3.      Attach it to any running server [who are in same availability zone] as data disk [/dev/xvdg – device name of the disk given by AWS at the time of attaching it]
4.      Start the Instance from AWS console

5.      mount the disk on OS
[root@cloud_home2]# mount /dev/xvdg2 -o no-uuid /mnt ; cd  /mnt ; ls -l usr/bin/sudo

6.      Change permission of /usr/bin/sudo
[root@cloud_home2]# chmod u+s /mnt/usr/bin/sudo ; ls -l usr/bin/sudo

7.      Un-mount temporary mount point
[root@cloud_home2]# umount /mnt

8.      Detach the disk from this server
9.      And re-attach to original server as root disk where we are getting problem.
10. Start instance
11. Login with ec2-user

12. Now try to do sudo and this time you will be able to it.

[ec2-user@cloud_home]# sudo –i
[root@cloud_home]#

Regards,
Kirraan Jadhav