Created
August 3, 2016 13:39
-
-
Save tomwhoiscontrary/03d05c2fc0461cbfad48f1f9834dc3eb to your computer and use it in GitHub Desktop.
Script to load an SSH key for a day's work
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 -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