原文:http://stackoverflow.com/questions/4083079/how-to-run-git-ssh-authentication-agent
If you're using Msysgit, you can find a good tutorial here: http://anterence.blogspot.com/2012/01/ssh-agent-in-msysgit.html
- Add a file called
.bashrc
to your home folder -
Open the file and paste in:
#! /bin/bash eval `ssh-agent -s` ssh-add
- This assumes that your key is in the conventional ~/.ssh/id_rsa location. If it isn't, include a full path after the
ssh-add
command. -
Add to or create file
~/.ssh/config
with the contentsForwardAgent yes
In the original tutorial the
ForwardAgent
param isYes
, but it's a typo. Use all lowercase or you'll get errors. - Restart Msysgit. It will ask you to enter your passphrase once, and that's it (until you end the session, or your ssh-agent is killed.)
[EDIT] If you don't want to start a new ssh-agent every time you open a terminal, check out Keychain. I'm on a Mac now, so I used this tutorial to set it up, but I'm sure a Google search will have plenty of info for Windows.