RE: One method to recover a lost root password



From Derekj Tourneo on Friday, March 16, 2007 4:46 PM

How I recovered a lost root password in FreeBSD

Luckily I did know one user name and it had no password.
cgadmin

going to the repair mode with CDROM/DVD option off the
install menu, using the "live" CDROM filesystem gave me a
root prompt Fixit#

now mounting the hard drive, in my case /dev/ad0s3a

mount /dev/ad0s3a /mnt
...

now change permissions, but look at them first, make a note
so you can put them back to the correct setting later chmod
777 /mnt/etc chmod 666 /mnt/etc/master.passwd

reboot

remove the CD and reboot the original system.
For some reason my older FreeBSD version 4.3 filesystem did
not like being mounted onto a FreeBSD 6.1 install CD Hence on
reboot it made me do a manual fsck Then another reboot

Now login as a user, cgadmin in my case
get a prompt and run

pwd_mkdb /etc/master.passwd

You don't need to know another account nor do you need all those other steps. After you edit the /etc/master.passwd file by booting from the fixit CD simply:

pwd_mkdb -d /mnt/etc master.passwd

If pwd_mkdb is not on the fixit CD -- I don't remember if it is -- you can run it from your hard drive something like this, depending on what partition it's on:

/mnt/usr/sbin/pwd_mkdb -d /mnt/etc master.passwd

Then just reboot and log in as root.

David



_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: One method to recover a lost root password
    ... How I recovered a lost root password in FreeBSD ... remove the CD and reboot the original system. ... cgadmin in my case ...
    (freebsd-hackers)
  • Re: Locked Myself Out - Cannot "su"
    ... I've been working on hardening my FreeBSD 6.2-Stable box. ... root login from everywhere, including the console (The box isn't ... didn't reboot after making all these changes to harden ...
    (freebsd-questions)
  • cant su to root
    ... Have FreeBSD 4.3.release ... Accept only if login as root. ... reboot, config -r CORE, make depend, make, make install, reboot ...
    (FreeBSD-Security)
  • Re: cant su to root
    ... "Radzivilyuk V.O." ... > Have FreeBSD 4.3.release ... > Accept only if login as root. ... > + reboot, config -r CORE, make depend, make, make install, reboot ...
    (FreeBSD-Security)
  • How to have a late night heart attack...
    ... moving my "send an email" shell script over to ... Tried to control the machine via ARD. ... The only damn way onto this machine is SSH as root. ... Reboot again, finally everything behaving. ...
    (uk.comp.sys.mac)