FreeBSD recover a lost root password

859阅读 0评论2012-05-10 ulovko
分类:BSD


  1. How I recovered a lost root password in FreeBSD

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

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

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

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

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

  10.     mount /dev/ad0s3a /mnt

  11. now edit the master password file

  12.     vi /mnt/etc/master.passwd

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

  17. save the file

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

  22. reboot

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

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

  30.     pwd_mkdb /etc/master.passwd

  31. This rebuilds the secure password database

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

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

  38. 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

FROM: 
上一篇:cp显示进度百分比
下一篇:培亚RHCE教程原版DVD(终于找到了,但是速度挺慢的!)