Skip to content

Instantly share code, notes, and snippets.

@codeword
Created July 21, 2015 17:07
Show Gist options
  • Save codeword/441fde288a41666c437d to your computer and use it in GitHub Desktop.
Save codeword/441fde288a41666c437d to your computer and use it in GitHub Desktop.
Tool to enable easy ssh keyfob management
#!/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