I installed zsh on my raspberry pi and for various reasons including the fact that the shell completely slowed down, I decided to remove it. I uninstall the package, changed the shell back to /bin/bash and assumed all would be ok. However, It looks like there was an issue uninstalling it.

When I tried to log back into the pi, via SSH, I was shown the following:

Welcome to KRATOS
Permission denied (publickey).

I know that the public key was fine as it's worked in the past, so I hooked the pi up to a monitor to see the log as it awoke. It ran everything as expected, and then when I attempted to login with the username and password of pi, it logged me in, then presented the error and proceeded to log me out.

Cannot execute /usr/bin/zsh: No such file or directory

The same happens when I try to login as root.

Have I completely locked myself out of the system, or is there a way of getting back in? Worst comes to worst, I can try and mount the filesystem onto another laptop and change the configuration from there?

  • Can you try specifying bash as the shell with the ssh command ? ssh -t root@host bash – GregHNZ Mar 25 '16 at 23:22

I guess that the default shell for root user is /usr/bin/zsh This is configured in /etc/passwd Do you have another account on that system with another default shell? If so, if you have configured sudo perhaps it's possible to edit the /etc/passwd file with sudo and change the default shell to /bin/sh or /bin/bash.

Otherwise you have to mount the filesystem/disk from a bootable usb-stick or do a network boot, or mount it from another device and fix it that way.

  • Fantastic, I did have another user on the system - by chance! – max_ Mar 25 '16 at 23:34

If you first do sudo apt-get update && sudo apt-get upgrade (this will give you temporary permissions as root, even with the previous error)

then do sudo nano /etc/passwd and change the default for root from /usr/bin/zsh to /bin/sh or /bin/bash and it will work. (just solved doing that. Thank you Mark van Herpen for help)

  • What does sudo apt-get update && sudo apt-get upgrade have to do with this question?  How is the user supposed to issue this command line when he can't get to a shell prompt? How does your answer "give [the user] temporary permissions as root"? – Scott Aug 4 '18 at 20:01

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.