Linux – Unable to login as root or as user because zsh is missing

debianlinuxraspberry pishellzsh

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?

Best Answer

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.

Related Question