January 24, 2013

Github and ssh authentification

I had to set up git for 2 different accounts, but ssh-agent did not allow me to add anything. I found few solutions but none of them was working in my case. Windows 7 runs on my machine. Eventually I found one article which solved my problem, since that ssh-agent is running always when I execute Git bash. Here's the link:


Update  Januar 24th:

It stopped working, agent was not able to run thus I couldn't fetch anything. The error which was display : bind I was struggling with it again until I tried to change this script:
Re-use existing ssh agent [www.electricmonk.nl]

It executes ssh-agent and automatically add one of my keys when I run git bash:

export SSH_AUTH_SOCK=/tmp/.ssh-socket

ssh-add -l >/dev/null 2>&1
if [ $? = 2 ]; then
   # No ssh-agent running
   rm -rf $SSH_AUTH_SOCK
   ssh-agent -a $SSH_AUTH_SOCK >/tmp/.ssh-script
   source /tmp/.ssh-script
   echo $SSH_AGENT_PID > /tmp/.ssh-agent-pid
   rm /tmp/.ssh-script
 # add key only if ssh agent is not running
  ssh-add c:/Users/xxx/.ssh/ssh_key