I bought a TP-Link WR841N a few days ago - you can read the story of installing OpenWRT on it. By five days later I've already forgotten/lost the root password. So today's blog entry is about how to remedy that. Happily, it's a short entry.
Normally, I'd just say "go look at the OpenWRT Wiki entry about the router," but it turns out that their entry on how to get this particular model into Failsafe mode isn't entirely accurate. Maybe Canadian WR841N models are different, or maybe they're referring to the WR842N that they seem to conflate with it in the article.
Failsafe mode resets the router to the same state it was in immediately after you installed OpenWRT (your changes aren't lost, they're just temporarily set aside). Getting into Failsafe mode is hardware-specific: how you do it on a Linksys WRT54G is different from how you do it on a TP-Link WR841N. But resign yourself to the fact that anyone with physical access to your router can gain root access with ease.
To get Failsafe on the WR841N: switch the power off with the power button on the back. Wait a few seconds (probably not essential, just my habit). Turn the power on: the system power light comes on. Shortly after that the light on the far end of the row under the lock symbol will start to blink: immediately press and hold "WPS/RESET" button on the back of the device: after three-to-four seconds, the Lock light will start to flash much faster. Let go of "WPS/RESET" and wait a short time for the router to fully boot.
Plug a computer into one of the four LAN ports on the router. As root on the computer, set the IP with something like
ifconfig eth0 192.168.1.73 netmask 255.255.255.0 up. Now as a user type
telnet -l root 192.168.1.1. This should log you in without a password. I have the latest OpenWRT (the version name is "Chaos Calmer"), and I'm happy to see that when you login in Failsafe mode it now tells you A) you're in that mode, and B) a couple basic things you might like to do, like changing the password. I followed their instructions for that (which also work in other OpenWRT versions): first, type
mount_root to bring your changes into play (they're stored on an overlay partition which mount_root mounts). Then use the standard Unix
passwd utility to change the password, and finally reboot. This will be a normal boot, and you should now be able to log in again.