Recently i came across this little problem. I have a Linux Debian VPS which i use to run some websites. I had disabled Root Login on the VPS and would elevate privileges using ‘su’ command after first logging in as a normal Linux user. But this morning when i tried the ‘su’ command i got this error:
su: authentication failure
First i thought i had forgot the root password but after reconfirming i noted that i was using the right password. My second method to get root access was by using the following command
$: sudo su root
But this also failed because when i entered the password for my user i got the error that my normal Linux user was not in sudoers list. This had practically locked me out of my Linux VPS. One thing i checked was the permissions for the ‘su’ command by running the following command:
$: ls -l /bin/su
The output showed
This meant that the SUID bit which should have been set to s was set to x. The correct permission should have been -rws-x–x. This can be corrected by logging in as Root and running the following command:
chmod +s /bin/su
However, the problem here was that i could not get Root access because i could neither use su command nor i could use sudo command to get root privilege. However, after doing some experimentation the following command following worked and it added the normal Linux user to sudoers group. The command was run without the root privileges and it even threw and error but effectively added the Linux user to sudoers. After that i ran ‘su’ command successfully and the root password worked without any error.
echo ‘<username> ALL=(ALL) ALL’ >> /etc/sudoers
NOTE: remember to change <username> with the normal Linux username of your Linux machine.
This was successful on a Linux OpenVZ VPS running Debian 6 32 bit. Hope it helps if you are caught in the same cycle.