Skip to content

Instantly share code, notes, and snippets.

@apg
Created January 17, 2013 21:41
Show Gist options
  • Save apg/4560056 to your computer and use it in GitHub Desktop.
Save apg/4560056 to your computer and use it in GitHub Desktop.
Best way to start an ssh-agent that I know of. Stick it in your .bash_profile for ultimateness.
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
if ! ([ -S "$SSH_AUTH_SOCK" ] && { ssh-add -l >& /dev/null || [ $? -ne 2 ]; }) ; then
echo "Starting agent..."
eval "$(ssh-agent -s -a $SSH_AUTH_SOCK)" > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment