Every Mac OS X system in my company uses 3 local users accounts.
1st user is a local administrator user, the 2nd user is a local standard user and the 3rd user is a local administrator user.
The 3rd user account is being used from my Security Department to scan our Mac OS X systems.
This 3rd user has never been logged into the system.
The 3rd user is there, but this user does not have a regular /Users/username
path folder. Again it is there, I can use it, I can SSH, etc. but once again does not have a regular /Users/username
home path because we never log in.
I need to create a bash script that will change and update this 3rd user password.
Surfing the web, I found this solution:
sudo /usr/bin/dscl . -passwd /Users/username newpassword
sudo security set-keychain-password -o oldpassword -p newpassword /Users/username/Library/Keychains/login.keychain
My problem is that the user does not have a regular /Users/username
home path, because we never log in. We just created the user so the Security team can use it for scanning.
How can I create a bash script that will change the password?
Just so you know, the user has been created with the following script:
USERNAME="Batman"
USERFULLNAME="Batman Scan User"
USERUID="512"
USERPASS="BatmanPassword"
dscl . -create /Users/"${USERNAME}" isHidden 1
dscl . -create /Users/"${USERNAME}" UserShell /bin/bash
dscl . -create /Users/"${USERNAME}" RealName "${USERFULLNAME}"
dscl . -create /Users/"${USERNAME}" UniqueID "${USERUID}"
dscl . -create /Users/"${USERNAME}" PrimaryGroupID 20
dscl . -create /Users/"${USERNAME}" NFSHomeDirectory /Users/"${USERNAME}"
dscl . -passwd /Users/"${USERNAME}" "${USERPASS}"
dscl . -append /Groups/admin GroupMembership "${USERNAME}"
NFSHomeDirectory
is set to/Users/Batman
; does that directory exist? If it does, does/Users/Batman/Library/Keychains
exist, and does it contain a login.keychain and/or a subdirectory with a GUID for a name?passwd
against the user?