2

I have mysysgit and TortoiseGit installed on a Windows PC, which connects to a remote Git repo on a Linux box. I have created ssh keys, and added them to the profile in TortoiseGit. When I interact with the remote repo in TortoiseGit, it all works fine. No password prompting. However, when I try to run Git commands from the command line, I get prompted for the SSH password.

What do I need to do so that I'm not prompted for the password from the command line?

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
scott80109
  • 361
  • 6
  • 25

3 Answers3

4

Make sure your git session references the TortoisePLink.exe (in GIT_SSH environment variable), as described in "Why git can't remember my passphrase under Windows":

(you might have done the first two steps already)

  • convert your key for use with TortoiseGit's pageant.exe using TortoiseGit's puttygen.exe.
  • Run TortoiseGit's pageant.exe, open your .ppk file ("Add Key"), and provide your passphrase for your key.
  • add the environment variable:

    GIT_SSH=C:\full\path\to\TortoisePlink.exe
    

This assumes your TortoiseGit is using TortoisePlink.exe.


The OP scott80109 concludes in the comments:

msysgit was installed to use Open SSH.
I changed it to use plink, and it now works without a prompt


Erez A. Korn adds in the comments:

I prefer to use openssh as it doesn't require me to have my key in an alternative format (ppk).
I've written a small wrapper to launch the ssh-agent and take care of business and then added it to my Windows Startup.
You can check the code in erezak/ssh-agent-wrapper-win.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. Your post help me resolve it. msysgit was installed to use Open SSH. I changed it to use plink, and it now works without a prompt. – scott80109 Sep 26 '13 at 19:19
  • 1
    I prefer to use openssh as it doesn't require me to have my key in an alternative format (ppk). I've written a small wrapper to launch the ssh-agent and take care of business and then added it to my Windows Startup. You can check the code in https://github.com/erezak/ssh-agent-wrapper-win – Erez A. Korn May 13 '15 at 08:21
  • @ErezA.Korn Very nice! I have included your comment in the answer for more visibility. – VonC May 13 '15 at 08:31
0

I recommend to use pageant. read this http://guides.beanstalkapp.com/version-control/git-on-windows.html and add you ssh-key to pageant. it affects globally.

Jongsu Liam Kim
  • 717
  • 1
  • 7
  • 23
  • Pageant is installed and the key has been added to it. I don't think that's the problem. – scott80109 Sep 24 '13 at 23:22
  • @scott80109, do you have the `GIT_SSH` environment variable correctly pointing to PuTTY's `plink.exe`? Otherwise plain Git for Windows won't find it and will use its built-in SSH client (a bundled port of OpenSSH client). See the second screenshot [here](http://nathanj.github.io/gitguide/installing.html). – kostix Sep 25 '13 at 09:32
0

My use case needed multiple github users with passphrase-protected ssh keys.

I sorted my ~.ssh/config file to use different keys for different repo domains, as described here

However, I don't want to type my passphrase every time, and I don't want to use ssh-agent.

Here's how I set up Pageant to ask for and remember my passphrase on Windows login:

  • Download the Putty Tools package
  • Win+R to open run dialog
  • shell:startup to open the auto start folder in windows explorer
  • Navigate to your Pageant folder in a separate Explorer window
  • Right click and drag PAGEANT.EXE to the Startup folder. Choose Create Shortcut
  • Right click the shortcut, properties, Shortcut tab
  • Find the path to your .ppk encoded keypair
    • generate one with PUTTYGEN.EXE if you need a new one
    • convert one with PUTTYGEN.EXE if you have a linux id_rsa file but no .ppk
    • win7+ : shift right click your key in Explorer, Copy as path
  • Append the key path to the C:\whatever\PAGEANT.EXE line
    • e.g: "Target: C:\putty\PAGEANT.EXE plato_cambrian.ppk plato.ppk"
    • If your keys aren't adjacent to PAGEANT you can use absolute paths or change "Start in:" which is Pageant's CWD
  • Open the shortcut or reboot, and type your passphrases

Also, for anyone on ubuntu/linux mint who ended up here, I documented similar steps here

Plato
  • 10,812
  • 2
  • 41
  • 61