Created
July 21, 2015 17:07
-
-
Save codeword/441fde288a41666c437d to your computer and use it in GitHub Desktop.
Tool to enable easy ssh keyfob management
This file contains hidden or 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
#!/usr/bin/env bash | |
HOURS=$1 | |
if [ -z $HOURS ]; then | |
echo "Usage: $0 <num hours>" | |
exit 1 | |
fi | |
ssh-add -D | |
ssh-add -t ${HOURS}H $(dirname $0)/id_dsa.github.secure | |
KEY=$(dirname $0) | |
COMMAND="diskutil umount force $KEY" | |
while true; do | |
read -e -p "Would you like to unmount '$KEY'? [Yn]" YN | |
YN=${YN:-y} | |
case $YN in | |
[Nn]* ) | |
echo "to eject Run: $COMMAND" | |
break;; | |
[Yy]* ) | |
echo "Unmounting, please be patient..." | |
eval $COMMAND | |
break;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment