Last active
October 5, 2017 20:56
-
-
Save flannon/7a7e448fbc7acf2965732dbfcf550c4c to your computer and use it in GitHub Desktop.
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
# start ssh-agent and load keys | |
SSH_AGENT=$(which ssh-agent) | |
SSH_AGENT_ARGS='-s' | |
# SSH_KEYS is a space separated list of ssh keys to load | |
SSH_KEYS='< -- your keys go here -->' | |
SSH_ADD=$(which ssh-add) | |
if [[ -z $SSH_AUTH_SOC && $SSH_AGENT ]]; then | |
eval $($SSH_AGENT $SSH_AGENT_ARGS) 2>&1 1>/dev/null | |
for i in $SSH_KEYS; do | |
$(echo $SSH_ADD) -k $HOME/.ssh/$i 2>&1 1&>/dev/null | |
done | |
# trap on sig 0 runs command on exit | |
# do $SSH_AGENT will die on logout | |
trap "kill $SSH_AGENT_PID" 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment