Created
December 7, 2015 15:34
-
-
Save gmarkall/24fb9be7d079b65d61d0 to your computer and use it in GitHub Desktop.
ssh-agent setup on windows with git bash 2.6.3
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
# Based on http://mah.everybody.org/docs/ssh | |
# set environment variables if user's agent already exists | |
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}') | |
[ -z "$SSH_AGENT_PID" -a "$SSH_AUTH_SOCK" ] && [ -n `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1)) | |
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK | |
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID | |
# start agent if necessary | |
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then # if no agent & not in ssh | |
eval `ssh-agent -s` > /dev/null | |
fi | |
# setup addition of keys immediately | |
if [ -z "$SSH_TTY" ] ; then # if not using ssh | |
ssh-add -l > /dev/null # check for keys | |
if [ $? -ne 0 ] ; then | |
ssh-add | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment