Sudo doesn't work: "/etc/sudoers is owned by uid 1005, should be 0" - Ubuntu

1

When I tried to change the user to root using sudo su command. it shows the below error. Is there away to solve this issue?

dasitha@dev-digin-io:~$ sudo su
sudo: /etc/sudoers is owned by uid 1005, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I am using below Ubuntu 14.04.5 LTS Server operating system.

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty

Here's ls output:

dasitha@dev-digin-io:/etc$ ls -l /etc/sudoers
-r--r----- 1 sajee root 900 Dec 9 07:02 /etc/sudoers

This is hosted in google cloud platform (compute Engine / VM ) so I don't have physical access to the machine.

Daz

Posted 2016-12-09T07:27:04.283

Reputation: 63

Please [edit] your question to include the output of ls -l /etc/sudoers. Also please tell us if you would be able to boot the server from alternative media (such as a live CD). – a CVn – 2016-12-09T07:29:18.087

Did you set up root password? Can you run su without sudo? – techraf – 2016-12-09T07:30:51.993

@MichaelKjörling this is the out put. dasitha@dev-digin-io:/etc$ ls -l /etc/sudoers -r--r----- 1 sajee root 900 Dec 9 07:02 /etc/sudoers – Daz – 2016-12-09T07:33:29.247

@techraf no still I got the authentication failure error message.

dasitha@dev-digin-io:/etc$ su Password: su: Authentication failure – Daz – 2016-12-09T07:34:44.763

No @techraf . This is hosted in google cloud platform. (compute Engine / VM ) – Daz – 2016-12-09T07:41:29.540

@Daz When people request more information, please edit the post to include it. I have made the edit for you; please make them yourself in the future. Thank you. – a CVn – 2016-12-09T07:46:58.563

When using su directly, you need the root password. This is different from sudo, where you use your user’s password. – Daniel B – 2016-12-09T07:47:04.500

I have the root password @DanielB. The issue is I can't access the /etc/sudoers. (Explained in the problem) – Daz – 2016-12-09T07:48:48.757

1If you know the root password, then did you provide it to su prompt? And did you get "Authentication failure" in response to the correct (at least in theory) root password? – techraf – 2016-12-09T07:52:21.783

2Actually, you can access /etc/sudoers. It’s just not secure anymore, so sudo refuses to use it. su does not use /etc/sudoers. However, like I mentioned, it requires you to type in the password for root. When exclusively relying on sudo, this password may not even be set! – Daniel B – 2016-12-09T07:53:28.750

Thanks for the information @DanielB. What I want to know is. Is there any way to make this thing work ? Or do I need to reinstall the OS ? – Daz – 2016-12-09T08:11:37.793

1As has been said: Use su with the root password to become root, then chown root /etc/sudoers to make it secure ("owned by uid 0"). – dirkt – 2016-12-09T08:59:10.953

Answers

1

On Google Cloud Platform you can use Startup Scripts to run commands as root on startup. So you can add something similar to chown 0 /etc/sudoers to your current script and restart your VM.

And you could read more about Startup Scripts on Article at Google Cloud Platform

Fedor Dikarev

Posted 2016-12-09T07:27:04.283

Reputation: 244