How to: OpenBSD reset root password

If you forgot your root password, you can simply reset it. The general procedure for resetting password is as follows (if you are a Linux user, see how to reset Linux root password):

a) At boot> prompt force openbsd to boot into a single user mode

b) Next mount file system in read-write mode

c) Run passwd command

d) Sync file system

e) Reboot and login normally.

Procedure to reset root password

At boot> prompt type boot -s to boot into single user mode:
boot> boot -s
Next you will see a message as follows:

Enter pathname of shell or RETURN for sh:

Just hit [Enter] key to load sh shell.
Next mount / and /usr file system in read-write mode:
# mount -uw /
# mount /usr

Finally set or change the password for root user, enter:
# passwd
Press CTRL+D to boot into multiuser mode or just reboot server:
# reboot

Further reading


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Jonathan Arnold Sep 19, 2007 @ 19:51

    The problem is that this method doesn’t work for many modern distros (like PC-BSD and openSUSE). They ask you for root password at boot time. In BSD, it is controlled, IIRC, by setting ‘secure’ in the /etc/ttys file for the tty. Not really sure how it is done in Linux. In openSUSE, there is a /etc/inittab file, and in there is a ‘what to do in single-user mode” comment that includes running /sbin/sulogin. Perhaps if this is commented out?

    Another discussion is here:

    http://linux.about.com/od/linux101/l/blnewbie3_2_3.htm

    This is how you can boot a Live CD and edit the /etc/shadow file to remove the root password.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum