Skip to content

Instantly share code, notes, and snippets.

@tomwhoiscontrary
Created August 3, 2016 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomwhoiscontrary/03d05c2fc0461cbfad48f1f9834dc3eb to your computer and use it in GitHub Desktop.
Save tomwhoiscontrary/03d05c2fc0461cbfad48f1f9834dc3eb to your computer and use it in GitHub Desktop.
Script to load an SSH key for a day's work
#! /bin/bash -eu
if [[ $# -gt 0 ]]
then
TIME=${1}H
else
END_OF_DAY=19
NOW=$(($(date +%s) % 86400))
EXPIRY=$((END_OF_DAY * 3600))
TIME=$((EXPIRY - NOW))S
fi
DIR="$(dirname "$0")"
KEY=$DIR/id_rsa
/usr/bin/ssh-add -D
/usr/bin/ssh-add -t $TIME $KEY
/usr/sbin/diskutil umount force $DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment