OpenWRT on WRT54G/S: reset the root password
*Do it on your own risk
If you’ve broken one of the startup scripts, firewalled yourself or corrupted the JFFS2 partition, you can get back in by using OpenWrt’s failsafe mode. Full failsafe mode is only working when you have installed one of the SquashFS images.
- Get ready
- Download the recvudp utility and save it somewhere (e.g. on your desktop).
- Unzip the recvudp-win32.zip file, enter the folder, change the file recvudp-win32 name to recvudp-win32.zip, unzip it again. You got 2 files with one exe file.
- Open a DOS shell (a command prompt) and run the recvudp.exe that you have just saved
- Running it nothing will happen, the cursor will just blink on the following line. That’s ok.
- Set static IP in your computer to say, 192.168.1.2, connect it to the OpenWRT, switch it on.
- Put the WRT in Failsafe mode
- In the DOS window you have open in first step, you will notice that the following message appears:
Msg from 192.168.1.1: Press reset now, to enter Failsafe!
- When the above message appears, press and hold the reset button for 2 seconds. You should now get the message:
- In the DOS window you have open in first step, you will notice that the following message appears:
Entering Failsafe!
Once in failsafe mode, the router will ignore the configuration and use the ip address 192.168.1.1 and will boot directly into a telnet server, bypassing normal boot up. There will be no DHCP server, and the JFFS2 partition won’t be mounted.
OpenWrt itself uses the reset button to enter into failsafe mode, and for no other purpose. In particular, it will not reset the NVRAM. The boot loader, however, may reset the NVRAM in response to the reset button. Therefore, it’s important to know what’s running when you hold down the reset button. One indicator is that OpenWrt will light the DMZ LED (on systems that have one) from the time it begins until the time the bootup scripts complete. If the DMZ LED has not yet lit up, you are still in the bootloader!
Resetting the NVRAM will brick some models.
4. Telnet OpenWRT at 192.168.1.1
5. Apparently when in Failsafe mode telnet drops right into a shell. Cool !
6. mount the jffs file system :
- mtd unlock /dev/mtd/4
- mount -t jffs2 /dev/mtdblock/4 /jffs
7. vi /jffs/etc/passwd
- First time, I don’t know the original one in passwd, so change root line to the following I found online: root:$1$$oYzVKLfly6aIyQZGRB/WW0:0:0:root:/tmp:/bin/ash
- Or change it to the following which is from the passwd file after I changed the password back to admin: root:$1$94$gPojrAnI0oPZSeHEJh/YF.:0:0:root:/tmp:/bin/ash
8. Reboot, back to normal.
9. If you change root line using first one, admin password was set to amsterdam, 2nd one, admin.
Sphere: Related Content