2

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!

jscott
  • 24,204
  • 8
  • 77
  • 99
SimonDowdles
  • 131
  • 2
  • Did you try sudo -i ? – Bart De Vos Apr 05 '11 at 10:08
  • @jscott I tried pretty much evry trick in the book, and I only just realized that I was not running my commands relative to the /media/xvda location but rather as / and therefore all my edits were relative on the RECOVERY IMAGE and not my mounted location. Silly silly error. But solved. – SimonDowdles Apr 05 '11 at 10:23

1 Answers1

1

@All,

This was a silly mistake, but I have solved it. When booting up with the recovery image for the VPS, I had to mount my /dev/xvda to /media/xvda however when running commands such as sudo nano /etc/passwd they were running relative to the RECOVERY IMAGE and not my mounted location.

Simply running sudo nano etc/passwd sorted this whle mess out because now I was editing /meda/xvda/etc/passwd instead of [RECOVERY IAMGE]/etc/passwd

I change the shell back to /bin/bash for root and SSH access was restored.

I hope someone can take something away with them from this silly mistake of mine.

SimonDowdles
  • 131
  • 2