OpenWrt Forum Archive

Topic: Locked-out after editing /etc/passwd (can't get into failsafe either)

The content of this topic has been archived on 9 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello guys,

so I installed bash, and manually edited /etc/passwd to replace /bin/ash with /bin/bash, and, like an idiot, without testing with a new connection, hastily logged out and tried to log back in, and now dropbear won't let me back in, saying: "Permission denied, please try again." sigh... :-(

I tried getting into failsafe just as suggested here: http://wiki.openwrt.org/OpenWrtDocs/Troubleshooting , but the reset button does not seem to have any effect. What else can I do to get back control of this box?

This is WRT54G v2 with Kamikaze 7.09

no clue how you installed bash... but that aside... there's 2 possible problems you're running into.

#1 bash wasn't installed correctly and you're unable to get a shell to start.  (could be anything.. missing libraries... incorrect file locations..  incorrect file permissions)
#2 you skrewed something else in the passwd file...

Easiest fix... reflash.

semi-harder fix... not sure if scp will work... but get a passwd file that is correct... and scp it over to the wrt... and overwrite the existing one.  I honestly don't remember if an scp session will start bash or not.

(Last edited by TheCompWiz on 6 Mar 2008, 15:47)

Or enter failsafe mode and copy the passwd file from /rom/etc/passwd to /etc/passwd.

Another option is to reset all your changes you have made after reflashing. Do this by entering into failsafe mode and clean the JFFS2 partition with 'mtd -r erase rootfs_data'.

Hi,
It's funny 'cos I did exactly the same "mistake" once. There is another possibility if you have webif² installed. There is a web file editor in web if wink Hope it helps

cheers,
Tex

OK, problem solved! Apparently when they say IMMEDIATELY press the button, and for exactly 2 secs - they aren't kidding!!! :-)

I kept twiddling with the damn reset button until I finally got the timing right and lo and and behold - failsafe appeared! :-)

Thanks for your suggestions guys!

TheCompWiz wrote:

no clue how you installed bash...

fairly easy:

ipkg install bash

:-)

#1 bash wasn't installed correctly and you're unable to get a shell to start.  (could be anything.. missing libraries... incorrect file locations..  incorrect file permissions)

IDK, it starts and works just fine when I call it from ash... :-/

#2 you skrewed something else in the passwd file...

The only thing I changed was added letter "b" in front of "ash", so IDK... :-/

Easiest fix... reflash.

Apparently my problem was inability to time the DMZ light accurately enough :-)

semi-harder fix... not sure if scp will work... but get a passwd file that is correct... and scp it over to the wrt... and overwrite the existing one.  I honestly don't remember if an scp session will start bash or not.

scp gave the same error as ssh

forum2008 wrote:

Or enter failsafe mode and copy the passwd file from /rom/etc/passwd to /etc/passwd.

when I finally did get into failsafe I had to mount_root and then edit /jffs2/etc/passwd and take out that "b" in front "ash"

Tex-Twil wrote:

Hi, It's funny 'cos I did exactly the same "mistake" once. There is another possibility if you have webif² installed. There is a web file editor in web if wink Hope it helps

No, no webif here, I don't think its available for Kamikaze yet... :-/
SSH is the only way in, but I finally got into failsafe, so its all cool now :-)

I did exactly the same thing, i followed the wl700g.homelinux.net install instructions so i had already installed the webif interface which allowed me to modify the passwd file and remove that pesky little b from in front of "ash".  Ironically enough, i DIDNT see that message at the bottom that said apply changes, so i went in and tried to login again and of course I couldnt.  I finally resulted to just using the webif editor to DELETE BASH completely from /bin/ thinking that maybe the system would automagically default to /bin/ash ? or maybe just /bin/sh??? Well, i did delete it, and THEN did i realize that i could hit apply to save my changes, luckily, so i was able to log back in with SH. I am currently investigating why i added another user and cannot start /bin/bash by logging into that users account.
Be back in a bit.

So i just rebooted the router after having added /bin/bash to /etc/shells and additionally adding my new user to the /etc/groups file, i doubt any of those changes really made it work, i think I just need to reboot?

Still not sure what made it work.

Good luck! and remember always add another USER first smile
gosh im lucky.

Probably was the /etc/shells thing. All valid login shells are supposed to be in there on a normal unix system. Not sure about openwrt though. Strange that the bash package did not cause bash to be added automatically.

Wodin wrote:

Probably was the /etc/shells thing. All valid login shells are supposed to be in there on a normal unix system. Not sure about openwrt though.

Ah ha! Words of of wisdom these are indeed! :-)

I just added a new user (what I should've done in the first place...), added /bin/bash to /etc/bash, and now it works as the new user's login shell!

Strange that the bash package did not cause bash to be added automatically.

Yeah... this is something I've come to expect from a package manager (after some years with Debian), perhaps I should file a bug report about this?

johnsmithdoe wrote:

No, no webif here, I don't think its available for Kamikaze yet... :-/
SSH is the only way in, but I finally got into failsafe, so its all cool now :-)

webif² is available for Kamikaze.

The discussion might have continued from here.