Created
June 28, 2018 07:37
-
-
Save wyrmiyu/636268b4d3c695a561969d18bd1cb9f8 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
SSH_AGENT_PID=999999999999999 | |
if [ -r ~/.ssh/agent ]; then | |
source ~/.ssh/agent >/dev/null | |
fi | |
if [ -r "/proc/$SSH_AGENT_PID/exename" ]; then | |
if [[ $(basename $(cat /proc/$SSH_AGENT_PID/exename)) != ssh-agent ]]; then | |
rm -f ~/.ssh/agent $SSH_AUTH_SOCK | |
unset $SSH_AGENT_PID | |
fi | |
else | |
if [ -n ${SSH_AUTH_SOCK+x} ]; then | |
unset SSH_AUTH_SOCK | |
SSH_AGENT_PID=9999999999999 | |
fi | |
fi | |
if [ -z ${SSH_AUTH_SOCK+x} ] || [ ! -S "$SSH_AUTH_SOCK" ]; then | |
rm -f ~/.ssh/agent $SSH_AUTH_SOCK | |
[ -z ${SSG_AUTH_SOCK+x} ] || unset SSH_AUTH_SOCK | |
if [ -r "/proc/$SSH_AGENT_PID/exename" ]; then | |
if [[ $(basename $(cat /proc/$SSH_AGENT_PID/exename)) == ssh-agent ]]; then | |
kill $SSH_AGENT_PID | |
fi | |
unset SSH_AGENT_PID | |
fi | |
ssh-agent > ~/.ssh/agent | |
source ~/.ssh/agent | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment