2

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.

5

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.

  • 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
0

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

  • Not working. Permission denied. – Clark Gaebel Aug 5 '10 at 3:44
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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