How to: OpenBSD reset root password

Posted on in Categories OpenBSD, Sys admin, Tips last updated September 19, 2007

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

1 comment

  1. 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 Comment