Mac Script to change Administrator password
I am looking for a UNIX/Mac command line to run on all my Macs to change the Administrator password.
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
krimkus
15 years ago
Posted by:
knowmad
14 years ago
How about passwd or you can do it on 10.5 and higher like this:
but then don't forget to also change the keychain password to match
but to my knowledge that must be done when logged in as the user... also this requires a lot of sending passwords over the network or hardcoding them into your scripts..... you may want to look into other options or be REAL careful about dumping that script when your done.
/usr/bin/dscl . -passwd /Users/[user short name] [password]
but then don't forget to also change the keychain password to match
security set-keychain-password -o [oldpass] -n [NEWPASS]
but to my knowledge that must be done when logged in as the user... also this requires a lot of sending passwords over the network or hardcoding them into your scripts..... you may want to look into other options or be REAL careful about dumping that script when your done.
Comments:
-
The first command worked for me. However, the second one required the location of the keychain. It looks like:
sudo dscl . -passwd /Users/test opassword
sudo security set-keychain-password -o npassword -p opassword /users/test/Library/Keychains/login.keychain - cmora 10 years ago
Posted by:
MacDude
10 years ago
Another script note that it will have teh password in cleartext.
#!/bin/bash
#for when you need to change the local admin (ladmin) accounts
password="your_password"
/usr/bin/dscl . passwd /Users/ladmin "$password"
status=$?
if [ $status == 0 ]; then
echo "Password was changed successfully."
elif [ $status != 0 ]; then
echo "An error was encountered while attempting to change the password. /usr/bin/dscl exited $status."
fi
exit $status
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.