Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently installed zsh as my shell on my laptop, and was loving the change. As a result, I decided to add it as the default on my server. I edited my /etc/passwd to point to /etc/zsh for my user and root (on the server), then exited from ssh.

Except I forgot to install zsh.

Now I can't log in as root or that user. I DO have physical access to the machine, but I'd rather not hook up a monitor. I also have access to a normal user account and know the root password. How do I go about fixing this?

Shouldn't need to be mentioned, but I can't install zsh without root access.

share|improve this question
up vote 5 down vote accepted

You can use the -s flag on su to specify the shell, so you can use su -s /bin/bash - to get to root using the bash shell.

share|improve this answer
I'm getting "permission denied" – Clark Gaebel Aug 5 '10 at 3:37
sudo su -s /bin/bash - if you're a sudoer – Sweet Aug 5 '10 at 3:47
Missing a space in the command. Fixed – Sweet Aug 5 '10 at 3:48
That works, thank you! – Clark Gaebel Aug 5 '10 at 3:51

You can execute a remote command by ssh, including another shell. You'll want to force a tty allocation so the shell can properly run. You can then run a root shell or edit files as necessary using sudo as normal.

ssh hostname -t /bin/bash

share|improve this answer
Not working. Permission denied. – Clark Gaebel Aug 5 '10 at 3:44
Interesting. Further experimenting seems to indicate SSHD restricts logins if the passwd-specified shell doesn't exist. The design reasons why seems to be some people/systems still use invalid shell for "disabling" a user. Apparently specifying a shell works fine only if you already have some other working shell. – Jeremy M Aug 5 '10 at 4:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.