Posted on 10-19-2015 04:35 PM
i'm currently running a script to have existing FileVault2 users key kept by the JSS. Here is the script i'm using...
adminName=$4
adminPass=$5
if [ "${adminName}" == "" ]; then
echo "Username undefined. Please pass the management account username in parameter 4"
exit 1
fi
if [ "${adminPass}" == "" ]; then
echo "Password undefined. Please pass the management account password in parameter 5"
exit 2
fi
userName=defaults read /Library/Preferences/com.apple.loginwindow lastUserName
OS=/usr/bin/sw_vers -productVersion | awk -F. {'print $2'}
userCheck=fdesetup list | awk -v usrN="$adminName" -F, 'index($0, usrN) {print $1}'
if [ "${userCheck}" == "${adminName}" ]; then
echo "This user is already added to the FileVault 2 list."
exit 3
fi
encryptCheck=fdesetup status
statusCheck=$(echo "${encryptCheck}" | grep "FileVault is On.")
expectedStatus="FileVault is On."
if [ "${statusCheck}" != "${expectedStatus}" ]; then
echo "The encryption process has not completed, unable to add user at this time."
echo "${encryptCheck}"
exit 4
fi
echo "Prompting ${userName} for their login password."
userPass="$(/usr/bin/osascript -e 'Tell application "System Events" to display dialog "JAMF requires a new key pair Please enter your login password:" default answer "" with title "Login Password" with text buttons {"Ok"} default button 1 with hidden answer' -e 'text returned of result')"
echo "Adding user to FileVault 2 list."
if [[ $OS -lt 8 ]]; then echo "OS version not 10.8+ or OS version unrecognized" echo "$(/usr/bin/sw_vers -productVersion)" exit 5
elif [[ $OS -eq 8 ]]; then
## This "expect" block will populate answers for the fdesetup prompts that normally occur while hiding them from output
expect -c "
log_user 0
spawn fdesetup add -usertoadd $adminName
expect "Enter the primary user name:"
send ${userName}
expect "Enter the password for the user '$userName':"
send ${userPass}
expect "Enter the password for the added user '$adminName':"
send ${adminPass}
log_user 1
expect eof
"
elif [[ $OS -gt 8 ]]; then
## This "expect" block will populate answers for the fdesetup prompts that normally occur while hiding them from output
expect -c "
log_user 0
spawn fdesetup add -usertoadd $adminName
expect "Enter a password"
send ${userPass}
expect "Enter the password"
send ${adminPass}
log_user 1
expect eof
"
fi
userCheck=fdesetup list | awk -v usrN="$adminName" -F, 'index($0, usrN) {print $1}'
if [ "${userCheck}" != "${adminName}" ]; then
echo "Failed to add user to FileVault 2 list."
echo "Currently enabled users:"
echo "${userCheck}"
exit 6
fi
echo "${adminName} has been added to the FileVault 2 list."
exit 0
i'm worried about the password being logged in the clear...
## This "expect" block will populate answers for the fdesetup prompts that normally occur while hiding them from output
expect -c "
log_user 0
spawn fdesetup add -usertoadd $adminName
expect "Enter a password"
send ${userPass}
expect "Enter the password"
send ${adminPass}
log_user 1
expect eof
"
fi
Would anyone have any ideas of how else to get this done? Thank you
Ed Millan
Posted on 10-19-2015 06:29 PM
There is a script button it looks like >_ you should put your script in there so it keeps the formatting nice
so it looks like this
#!/bin/sh
test=testing123