Skip to content

SSH-Agent in msysgit and cygwin and bash

Posted on:January 13, 2012 at 03:52 PM

Recently, at work, I had to do SSH forwarding. This was could only be done on msysgit (local machine Windows, remote Linux) when ssh-agent is running. After this great post on GitHub didn’t work for me, further Googling got me to the answer. What I did finally, is add the following:

#! /bin/bash
eval `ssh-agent -s`
ForwardAgent yes

After that, whenever you start msysgit it will ask you the passphrase for your key file, and not bother you with every git pull. Also, if you SSH into a remote machine to pull from there (some smarty-pants deployment tactic), you won’t have to place your private key in the remote machine for it to work with your git credentials.

EDIT: It has been pointed out a few times that the yes option for ForwardAgent command should be all lower case. I have corrected this now. Thanks to everyone for pointing this out.

EDIT 2: This works for cygwin, bash (Linux) and prompt in Mac as well. Basically any UNIX-like environment will make this work.

The original post can be found here: