Reading:
'/etc/sudoers' wrong owner

'/etc/sudoers' wrong owner

Metamug
'/etc/sudoers' wrong owner

You may have accedently changed the ownership of /etc/sudoers. You can check with the ls command

ls -lrth /etc/sudoers

It should show the following, but in this it will not.

-r--r----- 1 root root 755 Jul  4  2017 /etc/sudoers

Changing the owner back to root

If you try to change the owner, back to root

chown root:root /etc/sudoers
Unable to access /etc/sudoers
sudo: /etc/sudoers.d is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting

If you try to run the below command

Steps to Fix with 2 sessions

Open two SSH sessions to the target server.

  1. In the first session, get the PID of bash by running:
    echo $$
  1. In the second session, start the authentication agent with:
    pkttyagent --process 29824

Use the pid obtained from step 1.

  1. Back in the first session, run:
    pkexec chown root:root  /etc/sudoer
    pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
  1. Enter the password in the second session password promt. visudo will start in the first session.

In the below image, I have used Putty to make connections and logged in with the same user.

pkexec pkttyagent 2 ssh session



Icon For Arrow-up
Comments

Post a comment