Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

One method to recover a lost root password

7 views
Skip to first unread message

Derekj Tourneo

unread,
Mar 16, 2007, 5:36:22 PM3/16/07
to
How I recovered a lost root password in FreeBSD

This was on a CyberGuard LX firewall, running version 4.2 BSD

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

Using the boot CD, pick option 4 for single use mode
going through the country and keyboard

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 edit the master password file

vi /mnt/etc/master.passwd

on the root line, delete all characters between the first two :: to remove
the root password altogether.
hence ending up with
root::0:0::00:Charlie &:/root:/bin/csh or something similar

save the file

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

This rebuilds the secure password database

Now get another getty - say Alt-F4 and login as root
Amazing!!!!

Reboot if you like, set yourself a new root password and write it down this
time
I prefer a label on the bottom of the box, because if you have got this
access, you can crack the password.

Now don't forget to set the file security back to where it was
chmod 755 /etc
chmod 600 /etc/master.passwd

Hope you enjoyed the day.

Derek


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.11/723 - Release Date: 15/03/2007
11:27

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

David S. Madole

unread,
Mar 16, 2007, 6:02:21 PM3/16/07
to
> From Derekj Tourneo on Friday, March 16, 2007 4:46 PM
>=20

> How I recovered a lost root password in FreeBSD
>=20

> Luckily I did know one user name and it had no password.
> cgadmin=20
>=20
> going to the repair mode with CDROM/DVD option off the=20
> install menu, using the "live" CDROM filesystem gave me a=20
> root prompt Fixit#
>=20

> now mounting the hard drive, in my case /dev/ad0s3a
>=20
> =09mount /dev/ad0s3a /mnt
> ...
>=20
> now change permissions, but look at them first, make a note=20
> so you can put them back to the correct setting later chmod =20

> 777 /mnt/etc chmod 666 /mnt/etc/master.passwd
>=20
> reboot
>=20
> remove the CD and reboot the original system. =20
> For some reason my older FreeBSD version 4.3 filesystem did=20
> not like being mounted onto a FreeBSD 6.1 install CD Hence on=20

> reboot it made me do a manual fsck Then another reboot
>=20

> Now login as a user, cgadmin in my case
> get a prompt and run
>=20
> =09pwd_mkdb /etc/master.passwd

You don't need to know another account nor do you need all those other step=
s. 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 partitio=
n it's on:

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

Then just reboot and log in as root.

David

Garrett Cooper

unread,
Mar 16, 2007, 9:59:51 PM3/16/07
to
David S. Madole wrote:
>> 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

I am confused why this topic came up on this list..
-Garrett

Soeren Straarup

unread,
Mar 17, 2007, 1:54:09 AM3/17/07
to
On Fri, Mar 16, 2007 at 08:45:30PM -0000, Derekj Tourneo wrote:
> now edit the master password file
>
> vi /mnt/etc/master.passwd

Try: vipw -d /mnt/etc
It automaticly updates the right db(s)

Futher reading: man 8 vipw

/Soeren

--
Soeren Straarup | aka OZ2DAK aka Xride
FreeBSD committer | FreeBSD since 2.2.6-R
If a program is not working right, then send a patch

Robert Watson

unread,
Mar 17, 2007, 8:13:31 AM3/17/07
to

On Fri, 16 Mar 2007, Garrett Cooper wrote:

> David S. Madole wrote:
>>> 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#
>

> I am confused why this topic came up on this list..

Because it is a way to hack BSD, obviously. :-)

(It's gotten less frequent, but it used to be that once every few months an
e-mail would turn up on the list asking about how to hack FreeBSD systems...)

Robert N M Watson
Computer Laboratory
University of Cambridge

Matthew D. Fuller

unread,
Mar 17, 2007, 6:22:57 PM3/17/07
to
On Sat, Mar 17, 2007 at 06:49:02AM +0100 I heard the voice of
Soeren Straarup, and lo! it spake thus:

> On Fri, Mar 16, 2007 at 08:45:30PM -0000, Derekj Tourneo wrote:
> > now edit the master password file
> >
> > vi /mnt/etc/master.passwd
>
> Try: vipw -d /mnt/etc
> It automaticly updates the right db(s)

# chroot /mnt passwd root


--
Matthew Fuller (MF4839) | full...@over-yonder.net
Systems/Network Administrator | http://www.over-yonder.net/~fullermd/
On the Internet, nobody can hear you scream.

0 new messages