Created
August 5, 2014 23:52
-
-
Save mtougeron/8dc9cd42c1dd9bd566a3 to your computer and use it in GitHub Desktop.
A simple script to track your login password for scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) run | |
./sudo_askpass.sh set | |
and set the password to the keychain | |
2) run | |
export SUDO_ASKPASS=/path/to/sudo_askpass.sh | |
3) run | |
/do/my/script/to/install/things.sh | |
4) run | |
./sudo_askpass.sh del |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" == "set" ]; then | |
read -s -t 30 -p "Enter your sudo password: " pw | |
/usr/bin/security add-generic-password -U -l scripting-account-pw -a $USER -s "scripting: $USER" -w $pw | |
elif [ "$1" == "del" ]; then | |
_tmp=$(/usr/bin/security delete-generic-password -l scripting-account-pw -a $USER -s "scripting: $USER") | |
else | |
/usr/bin/security find-generic-password -l 'scripting-account-pw' -a $USER -w | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment