Accidentally revoked Sudo access

1

I'm pretty new to setting up http servers via PuTTy and managed to setup a EC2 server with Apache which works fine. The only issue is when trying to setup a few other things I managed to revoke my sudo access so now I can't install things I need to like PHP. Here's the error i'm getting:

sudo: /etc/sudo.conf is owned by uid 500, should be 0 sudo: /etc/sudoers is owned by uid 500, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin

Is there any way of giving myself back sudo access or installing php via another command?

Thanks

red house 87

Posted 2017-10-27T10:38:59.630

Reputation: 111

Answers

0

Use su - to switch to root using the root password and then repair the file ownership and permissions.

Ignacio Vazquez-Abrams

Posted 2017-10-27T10:38:59.630

Reputation: 100 516

hmm I don't recall ever setting a password although I did not setup the ec2 user myself. Is there a default password that comes with the default ec2-user? – red house 87 – 2017-10-27T14:15:19.127

I use a pem file normally to authorize my connection... – red house 87 – 2017-10-27T14:20:59.697

I don't know. You may need to futz around with the web interface. – Ignacio Vazquez-Abrams – 2017-10-27T14:40:18.227

EC2 instances have no root password by default. The suggested means of assuming the role of root is "sudo su" in the documentation, so you may be out of luck. – Corrodias – 2017-10-28T04:09:14.303

The only other option then would be to mount its volume somewhere else, possibly in another instance, and perform the repairs there. – Ignacio Vazquez-Abrams – 2017-10-28T07:19:31.460