Today is: March 9, 2010

Reset Forgotten OpenWRT Root Password

Unfortunately my password program was out of sync with the current password on my Linksys WRT54GS v.4 running OpenWRT RC5. After some searching I found what is IMHO the easiest solution for resetting the password. I've duplicated here in the event the entry 404s but all credit goes to http://rotz.org/ for the solution, I had nothing to do with this.

March 01, 2005
OpenWRT and resetting the root password

Facing a lost root password on a Linksys WRT54G with OpenWRT on a friend his ANC node is not a funny thing, it is not only embarrassing but this was also a first for me to fix this under OpenWRT.

To complicate things a bit we run dropbear on all our OpenWRT boxes. And disable telnet as we are security aware and cautious people.

Most people I consulted recommended to 'just reflash' the device but I was not that comfortable with it. There should be also something else possible....

So time for a Tech-Quest :

Howto reset the root password on a OpenWRT dated 17 Sept 2004 with telnet disabled and dropbear as ssh server with a v2 WRT54G.

I did cost me an hour or so to figure this out and I must say that the OpenWRT.org website has become a really great place to find the information you need, the UserGuide, the Support Page and the FAQ are really well written and have lots of examples and lots of neat HowTo guides can be found in the WIKI.

Still I did not find an easy 'howto reset your root password'.

That might be on purpose as maybe there is no such easy way and that is why this disclaimer :

DISCLAIMER :

The way of resetting the root password on an OpenWRT after forgetting it -did- work for -me-. It might -not- work for you.

Also you need to know I tried this with a v2 WRT54G, maybe with an older or newer version this does not work.

Do not blame me if it does not work for you or you 'brick' your WRT54G doing this. I warned you, I am not responsible.

On with the show :

After reseting the root password I discovered that this OpenWRT has installed :

* Linux OpenWRT 2.4.20 dated 17 Sept 2004
* BusyBox v1.00-rc2 (2004.09.17-08:16+0000)
* Dropbear 0.44test3

The steps I did to reset the root password were :

1.

Put the WRT in Failsafe mode
2.

Find out what the IP address is of the WRT in Failsafe mode on the Wireless. My WRT used SSID 'Linksys' and 192.168.1.128 as its IP address on the wireless network.
3.

I used another computer with an wireless card to join the Linksys
network and got over DHCP an IP address from the OpenWRT. This Failsafe mode is -very- nice work.
4.

Telnet using the wireless to my OpenWRT at 192.168.1.128

Apparently when in Failsafe mode telnet drops right into a shell. Cool !
5.

I mounted the jffs file system :

mtd unlock /dev/mtd/4
mount -t jffs2 /dev/mtdblock/4 /jffs

6.

And now I used a trick I used many many years ago when faced with a lost root password on a very simple unix system :

I edited the /jffs/etc/passwd file and replaced the password string with a string from a passwd file on a similar system that I did know the root password from. :)

And I have plenty of WRT54G devices with OpenWRT around me :)
7.

Reboot.

This worked like charm ! :)

The OpenWRT booted normal and started dropbear and olsrd as it was configured to do many many months ago and I could ssh to the box and use the 'new' root password.

In case you like to try this yourself and are wondering where to find a passwd file with a password string you know, I put one online here, the root password 'embedded' in the password string is :

amsterdam

and no, this is not the root password on any of my boxes. :)

Original URL: http://rotz.org/archives/2005/03/openwrt_root_pa.html

About You

Online Virus Scan