Search code examples
gitsshcygwinmsysgittortoisegit

Avoid the popup asking for username when doing git push


I have Cygwin, msysgit and TortoiseGit installed on my Windows machine. I am writing a script for Cygwin that does a git push to a remote machine via ssh:

git push ssh://host/path/to/git master:master

At this point, a popup appears and asks me the user I want to use for SSH. If I type a user, then I get a second popup that asks me for the password of that user. Now, I have two problems with that:

  1. That user authenticates using a key pair, so it doesn't have a password. The popup doesn't let me specify a private key.
  2. The reason why I'm writing a script is to avoid to have to repetitively write mundane things like username and private key location, so I would like to be able to pass the username and the path to the private key file to the command line (or maybe a config file).

Do you know how to do that?


Solution

  • When using a Windows computer, I use pageant to set a private key and automatically provide it to the requesting applications.

    So I have to give the private key password (to pageant) only once per session and not at every need. As pageant is an authentication agent, it works for all programs doing ssh connections (I tested it with msysgit with no problem).

    See : http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter9.html