0

Greetings

I am not able to add any users to the sudo users as my sudoers file has the wrong permission. My only access is SSH thus this(via recovery mode) solution doesn't seem to work for me.

I will be grateful for any idea. My ubuntu is 9.04 server edition.

Regards

user@server:~$ sudo nano /etc/sudoers 
sudo: /etc/sudoers is mode 0640, should be 0440
Segmentation fault

user@server:~$ sudo chmod 0440 /etc/sudoers 
sudo: /etc/sudoers is mode 0640, should be 0440
Segmentation fault
2
  • 1
    Unfortunately if you have no other way to login as root (ie an SSH account open with pubkey auth or a password defined for root to be able to su into it) you have no other way than to request someone with physical access to boot into recovery mode and do the fix. Aug 26, 2010 at 9:06
  • 1
    defraagh true, or wait for a root exploit to emerge ;)
    – Joris
    Aug 26, 2010 at 10:17

1 Answer 1

2

You need to log in as root, because you will not be able to use sudo until you fixed it. If you have set a root password, type su and go ahead. If not, you need some kind of rescue system or the possibility to change the kernel parameters in grub.

Are you able to boot into a rescue system? Then mount your root filesystem somewhere and change the permissions of the file to 0440.

Are you able to change the kernel options? then add init=/bin/sh to it and boot. When the prompt appears, change your password like this:

# mount -o remount,rw /
# passwd
  [...]
# mount -o remount,ro /
# reboot

Then boot up your server and get root with su. Disable the root password afterwards

A third option would be to use security leaks in your system to become root. But I can't and don't want to help you there

2
  • I was going to suggest those at first, but then I realized his only way to reach the server is via ssh. That complicates this issue a lot (unless he has enabled root account reachable via su ...). Aug 26, 2010 at 9:18
  • @Janne: You should still post your warning about using visudo (at least as a comment below the question). Aug 26, 2010 at 14:57

You must log in to answer this question.