ubuntuamazon-web-servicesamazon-ec2sudosudoers

How to fix this sudo: /etc/sudoers is world writable?


I am working on AWS EC2 machine. File permission of sudores file is,

-rwxrwxrwx 1 root root 902 Feb 5 12:22 sudoers

There are various question on this , but these not works. When i am trying to do,

sudo chmod 444 sudoers

This show error,

sudo: /etc/sudoers is world writable sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin

How to fix it ?


Solution

  • It's complicated and discussed here

    https://aws.amazon.com/premiumsupport/knowledge-center/ec2-sudoers-syntax-errors-sudo/

    Basically you detach the EBS volume from the EC2, mount it on another EC2, use root privs on that host to fix the file and then reattach it to the EC2