Created
September 10, 2014 16:38
-
-
Save genzj/effd1eba68fcfcec30e4 to your computer and use it in GitHub Desktop.
persistent ssh keys
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
SSH_ENV="$HOME/.ssh/environment" | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
# spawn ssh-agent | |
ssh-agent > "$SSH_ENV" | |
chmod 600 "$SSH_ENV" | |
. "$SSH_ENV" > /dev/null | |
} | |
# check for running ssh-agent with proper $SSH_AGENT_PID | |
if [[ -r "$SSH_ENV" ]]; then | |
. "$SSH_ENV" > /dev/null | |
ssh-add -l >/dev/null 2>&1 | |
if [[ $? == 2 ]]; then | |
start_agent | |
else | |
echo reuse ssh-agent $SSH_AGENT_PID | |
fi | |
else | |
start_agent | |
fi |
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
#~/.ssh/config | |
Host github.com | |
HostName github.com | |
User git | |
IdentityFile ~/.ssh/my-github |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment