password recovery for FreeBSD 4.11

I have an older machine with FreeBSD 4.11 installed. The problem was, that I was unable to log in because I had no idea about login name or password. I booted into a single user mode(boot -s), mounted all partitions which were defined in /etc/fstab file(mount -a) and changed root password using passwd root. However, before I realized this mount -a thing in order to have access to passwd utility, I changed /etc/passwd file manually using ed editor. It looked like this:


However, as second field should be the password, I was still unable to log in using root/24680 or martin/24680 as username/password. Any ideas, why this didn't work? Or any additional questions if my explanation was unclear :OOO
 
Use % vipw to edit the passwd file. Blank out the password field totally and save the file. Use % passwd to set a new password.
 
I'm not sure about FreeBSD 4.11 (I haven't touched this one), but usually you have to use vipw to edit passwd and master.passwd. In other case you should regenerate spwd.db and pwd.db by hand. In recent FreeBSD it is done by pwd_mkdb (8).
 
/etc/passwd doesn't contain the passwords for security reasons. If it did have passwords, they would not be in clear text (as you tried there). Instead, use passwd(1) to set the root user password. As noted, the actual passwords are in /etc/master.passwd which is protected by permissions. If you look in there, you will see something like:

Code:
root:$1$uJvh97IT$adOI70yILt/tRvQxU83r8.:0:0::0:0:Charlie &:/root:/bin/csh

The second field there holding the hashed password (which I changed, it's probably not even valid anymore).
 
Back
Top