Last active
January 8, 2019 14:23
-
-
Save krishnact/ed69fae0d2635655dbf2c6b0fccf128e to your computer and use it in GitHub Desktop.
How to use ssh agent in cygwin.
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
#!/bin/bash | |
#name this file as ~/bin/checkSshAgent.sh and put at the end of your ~/.bash_profile as shown below (remove the ##) | |
## | |
## . ~/bin/checkSshAgent.sh | |
## | |
AGENT_PID=`ps -ef | grep ssh-agent | grep -v grep | awk '{print $2;}'` | |
if [ -f ~/.ssh/agent-info ] | |
then | |
echo Agent info exists | |
else | |
echo SSH_AGENT_PID=xx0 > ~/.ssh/agent-info | |
fi | |
AGENT_PID_PUBLISHED=`cat ~/.ssh/agent-info | grep SSH_AGENT_PID | tr '=;' ' ' | awk '{print $2;}'` | |
if [ "x${AGENT_PID}" = "x${AGENT_PID_PUBLISHED}" ] | |
then | |
echo Using existing Agent | |
else | |
echo $AGENT_PID | xargs -n 1 kill -9 | |
ssh-agent > ~/.ssh/agent-info | |
. ~/.ssh/agent-info | |
ssh-add ~/.ssh/id_rsa | |
fi | |
chmod 700 ~/.ssh/agent-info | |
. ~/.ssh/agent-info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Last few lines of your bash_profile may look something like this after adding the checkAgent.sh file.