6

I love fish. I have a nice Ubuntu 8.04 Server running some services. So I edited the /etc/passwd file, as I did in the past, to change my default shell from bash to fish. And ,yes, I made I typo (BTW: I know about chsh, I'm just that stupid and overconfident). Please, stop laughing.

As expected, now I can't login. Is it possible log in without restarting the server?. I know that I can restart the server in safe mode and solve the mess, but I'd like to avoid it.

Oh yeah, I have no other user with sudo rights in that server. Stop laughing again.

BTW, I made the mess using ssh, but I have easy physical access to the server, it's just a couple of rooms away.

Javier Rivera
  • 35,434

3 Answers3

6

Unfortunately, no; you've locked yourself out. SSH won't let you log in if the shell is missing. Here's what the attempt looks like in /var/log/auth.log:

Dec 23 15:04:59 ubuntu sshd[5585]: User kees not allowed because shell /bin/fish does not exist

And on-console TTY login will always attempt to launch your configured shell. Without another user with sudo rights, you'll need to boot to single user mode to fix it. :(

Kees Cook
  • 17,823
1

If you have a root password set, you can either log in as root on the machine itself (Either in X or on a virtual console by hitting alt-F1), or remote in as a non-sudoing user and then switch to root using su in a terminal.

Of course, Ubuntu doesn't let you log in as root by default, so this assumes you had previously changed that.

0

If you want to restore some configuration files back to some previous state, you can always try to edit them, by booting your server with a Live version of some Ubuntu CD, mount the actual partition where the /etc files are located and edit them using vi.

You could also edit the file /etc/sudoers, in order to give more users the rights to become root.

jfmessier
  • 6,366