Cannot SSH because invalid shell

I installed zsh and changed /etc/passwd to /bin/zsh without double-checking if the binary is there.
Now I cannot SSH in and I cannot scp files. Any suggestions how I could edit the file or otherwise get a terminal? Is it possible from luci?

I installed znc-mod-webadmin, but it must not be running because nmap doesn't report it any new ports open.

LuCI has a Startup section that runs at boot. You can put your commands there, save, and reboot.

UPDATE: you can add a command to change default shell to something else. Or create a sym link to and existing shell.

I like this idea, but I am concerned about the lack of /bin/zsh stopping the booting from happening at all. Is the shell used by the initialization scripts the same as the one in /etc/passwd?

UPDATE: I tried something of a similar flavor. I created a cron job to modify /etc/passwd, but it failed and the logs say it's because it tried to use zsh to run the job.

Maybe luci-app-commands is worth a try.

The failsafe environment and mount_root will allow you to edit /etc/passwd.

Changing root's login shell is not recommended for the reasons you noticed. There are no fallbacks, if the referenced binary is missing (as it regularly will after a sysupgrade), you are dead in the water and need external recovery.


Based on your suggestion I was able to get luci to run basic shell commands for me.

sed -i "s/zsh/ash/g" "/etc/passwd"

Did the trick by replacing zsh with ash in place.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.