Osx-pwdrec

From Bashlinux
Revision as of 23:01, 7 March 2013 by Manpaz (talk | contribs)
Jump to: navigation, search

OS X password recovery

In general terms, before any specific step to change the password, we need to first

  1. Boot on single-user mode
  2. Mount the system in read-write mode
 # /sbin/fsck -fy
 # mount -uw /
 

How to change a password on OS X 10.4 or older

Once the root filesystem is mounted r/w on single user mode, the procedure is as follows:

 # sh /etc/rc
 # passwd my_user
 

How to change a password on OS X 10.5 with no installation DVD

Once the root filesystem is mounted r/w on single user mode, the procedure is as follows:

  1. Launch the directory services
  2. Change/reset the password
  3. Reboot the system
In short, the list of commands are:
 # launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
 # dscl . -passwd /Users/<username> <password>
 # reboot
 

How to change a password on OS X 10.8 with no installation DVD

Once the root filesystem is mounted r/w on single user mode, the procedure is as follows:

  1. Launch the directory services
  2. Change/reset the password
  3. Reboot the system
In short, the list of commands are:
 # launchctl load launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
 # dscl . -passwd /Users/<username> <password>
 # reboot
 

How to change a password on XServe

Once the root filesystem is mounted r/w on single user mode, the procedure is as follows:

 # nicl -raw /var/db/netinfo/local.nidb -create /users/$newuser _writers_passwd administrator
 # passwd administrator
 # reboot
 

How to create a new user with administrative privileges

First write down the gid which comes from admin group

 # nicl -raw /var/db/netinfo/local.nidb -read /groups/admin
 

Lets say, the gid is 20, then from command line execute:

 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user uid my_user_id
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user realname "My User Real Name"
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user passwd "my_user_passwd"
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user gid 20
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user shell "/bin/bash"
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user home "/Users/my_user"
 # nicl -raw /var/db/netinfo/local.nidb -create /users/my_user _writers_passwd my_user
 # passwd my_user
 # ditto /System/Library/UserTemplate/English.lproj /Users/my_user
 # chown -R my_user:staff /Users/my_user
 # nicl -raw /var/db/netinfo/local.nidb -read /users/my_user
 # nicl -raw /var/db/netinfo/local.nidb -append /groups/wheel users my_user
 # nicl -raw /var/db/netinfo/local.nidb -append /groups/admin users my_user