User Accounts with a random(ish) password revisited

March 8, 2014 | By More

User Accounts with a random(ish) password revisited…

I’ve been working on the thin deployment workflow over the last few weeks. The parental account is an area that is or has been problematic. Before I arrived the parental account had a hardcoded password. I never liked this and sort a way to change this. With our migration to Filewave came the opportunity to revise the account.

Please feel free to comment if there are any glaring errors.

#!/bin/bash

########################## # Create Parental Account # # Malcolm Summerton # Version 1.3.4 # Updated 17/03/2014 # Password generation changed # 8 didgit Random Pass Code # Force Password Change on Login # Securely Removes Script # Chnaged the way the Admin Acount is Applied # #########################

# Short name username=parent # Longname realname=”Parental Account” # Create Random Numeric 8 Digit Pass Code PASS=`jot -r -n 9 0 9 | rs -g 0` # FInd the Last User ID LastID=`dscl . -list /Users UniqueID | awk ‘{print $2}’ | sort -n | tail -1` NextID=$((LastID + 1))

# Marker File MARKER=/var/ppCreated.txt

# Create The Account # 1=Admin # 0-Standard User islocaladmin=1

## Do Not Edit Below this line ## dscl . -create /Users/$username Dscl . -create /Users/$username UserShell /bin/bash dscl . -create /Users/$username RealName “$realname” dscl . -create /Users/$username hint “…” dscl . -create /users/$username picture “/Library/User Pictures/Fun/Ying Yang.tif” dscl . -create /Users/$username UniqueID $NextID dscl . -create /Users/$username PrimaryGroupID 20 dscl . -create /Users/$username NFSHomeDirectory /Users/$username # Set the Password. dscl . -passwd /Users/$username $PASS

# Did we set the accout to Admin if [“$islocaladmin” == “1”]; then dscl . -append /Groups/admin GroupMembership $username fi

# Force Password Change on First Login pwpolicy -u $username -setpolicy “newPasswordRequired=1”

# create the marker touch /var/.ppc echo “Last Run: “`date` >> /var/.ppc touch $MARKER echo “Last Run: “`date` >> $MARKER echo “Password: “$PASS >> $MARKER echo “—–” >> $MARKER

exit 0

Category: Coding

About the Author ()

Comments are closed.