2 min read

A OpenWrt sysupgrade trap

So yesterday I upgraded my router to the latest version via Sysupgrade. The upgrade went fine without any problem. But when I tried to login to the router something went wrong. The ssh connection was reseted and closed.

Fuck! logout of my router! Does something wrong with dropbear? No no no… ssh is working fine. Ok check the documenation… what my I have change on the system that seems not be normal? Ah! I installed bash!

Looks like when you do a Sysupgrade on OpenWRT that all installed packages will be lost. Duo my use to bash, I did enable bash as default shell for root within /etc/passwd.

That must be the problem! But after the upgrade the router the bash package was gone. To fix this problem I had to start the router in a failsafe mode. The default shell of OpenWrt is ash or sh (A Shell or Almquist shell). After I enable the failsafe mode, I just had to run mount_root. Then I change the entrie within /etc/passwd back to ash. A reboot later my login was working again. Lucky me

But what I do to get my bash? Simple .profile has been made for this. Here the best solution for this:

[ -x /bin/bash ] && exec /bin/bash

So things to be learned: Don’t try to be smart and re-define system-shells within /etc/passwd/. Use your .profile for this.