So for some reason you just forgot the root password for your OPNsense router/firewall and you are now locked out and dont know what to do!!? Relax as in this article, we will show you How To Reset Or Recover Root Password On OPNsense from single user mode.
You can also check our previous guide on how to install OPNsense Firewall on VirtualBox.
Reset Or Recover Root Password On OPNsense
The first step in recovering lost or forgotten root password for opnsense router/firewall is to boot it to single user mode.
Therefore reboot OPNsense and once it boots, immediately press 2 on your keyboard to switch to Single User Mode from the loader menu as shown in the screenshot above. After it boots, you will be prompted to select the shell. Press Enter to start /bin/sh.
Before you can reset the password, you need to remount the drives as rewritable.
# mount -o rw /
OR to mount all the drives;
# mount -a -t ufs
Once you have mounted the drives, run the following command to reset the root password.
# /usr/local/etc/rc.initial.password
Follow the prompts to reset the password.
Reboot OPNsense.
# /sbin/reboot
And Voila!! This is how simple it is to reset or recover root password on OPNsense Firewall/router.
rc.initial.password is missing on OPNsense 19.x
Do you know an other solution ?
Hi, can you try the command;
opnsense-shell password
opnsense-shell password works perfectly! thanks a lot!
full path is /usr/local/sbin/opnsense-shell
On latest OpnSense : /usr/libexec/bsdconfig/040.password/password