I did a silly silly thing. While attempting to change the shell for user 'x' I was in a rush and did not type the users name at the end of the command, so I ended up running this:
chsh /sbin/nologin
This seemed to have then changed the default shell for root, to one that does not exists, and hence root can nolonger log in. I am running Ubuntu 10.04 LTS on a Linode VPS. Luckily, they give you a recovery console to boot into, from there you can mount your /dev/xdva to a location and edit the files. These are the steps I followed:
- Logged into recovery mounted
- /dev/xvda to /media/xvda and cd to
- /media/xvda/ Edited /etc/passwd and
- changed roots shell back to /bin/bash
- Added user 'onestp' to the sudoers
- list, as a fallback account for me
Now, I still cannot log into the VPS via SSH as root, it says access denied. I have tried to change the password but still no access. I can however log in as user onestp, but even when I sudo su -s /bin/bash root I still get the error message that the directory /sbin/nologin does not exists, even through I just changed the shell for root back to /bin/bash!
I can confirm that the shell is correct by typing sudo cat /etc/passwd | grep root which the outputs this:
root:x:0:0:root:/root:/bin/bash
Can anyone shed some light on this issue, I am at my whits end, have spent AGES configuring apache as a web server with php, mysql etc and reeeeealy do not want to rebuild.
For the record, I did not make a full image backup before this, no. Silly silly me!