Skip to content

Instantly share code, notes, and snippets.

@adrien-mogenet
Created January 28, 2016 09:01
Show Gist options
  • Save adrien-mogenet/c4009b9372f67aa2a39e to your computer and use it in GitHub Desktop.
Save adrien-mogenet/c4009b9372f67aa2a39e to your computer and use it in GitHub Desktop.
# Handle passphrase for ssh, to avoid typing it everytime.
# Note that we don't use -delete as this won't work properly on
# FreeBSD and MacOSX, and we need to redirect stderr to avoid
# the 'No such file...' error message.
SSH_WITNESS_FILE="/tmp/is_ssh_passphrase_ok"
SSH_TTL=86400
SSH_TTL_MINUTES=$((SSH_TTL / 60))
find "$SSH_WITNESS_FILE" -cmin "+${SSH_TTL_MINUTES}" -type f \
-exec rm -rf {} \; >/dev/null 2>/dev/null
if [ ! -f $SSH_WITNESS_FILE ]; then
ssh-add -t $SSH_TTL ~/.ssh/am-201601
touch $SSH_WITNESS_FILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment