1

The problem: When I try to use a ssh2-RSA key generated by puttygen with the command line git tool the key is rejected.

Details: I have TortoiseGit installed on my computer (as well as msysgit). TortoiseGit is set to use PuttyGen to generate it's keys. When I try to use one of the keys generated by PuttyGen in the command line git tool it denies the public key and in some cases will ask for a password even though the key has none. I have had this issue on multiple computers (all running windows 7 x64) any idea of how to get around this so i don't have to have separate keys for my cmd line client and TortoiseGit?

It may also be of interest that TortoiseGit is set to autoload a putty key for each repo form the push dialog. When i run ssh -v git@github.com it finds the key correctly but when it trys to connect it is rejected saying the key is wrong. If i use a key made by ssh-keygen it works just fine.

Software Versions: MsysGit 1.7.7.1 SSH 4.6p1 PuttyGen 0.61 Tortise 1.7.5.0

Thanks for your help (and if this is the wrong exchange to be putting this on please tell me so i can close and move it quickly) Eric Fode

kostix
  • 51,517
  • 14
  • 93
  • 176
Eric Fode
  • 3,667
  • 2
  • 24
  • 29
  • possible duplicate of [Configuring Git over SSH](http://stackoverflow.com/questions/1595848/configuring-git-over-ssh) – Eric Fode May 10 '12 at 04:33

1 Answers1

3

Duplicate of this one. In short: PuTTY (which puttygen is a part of) and OpenSSH (which ssh-keygen is a part of) use different format to store its keys, and you have to either stick to one of them or perform conversions.

Personally, I have set up Git to use plink.exe as its SSH agent and feed it keys via the pageant program which is PuTTY's ssh-agent.

To make it maybe more clear: Git for Windows bundles OpenSSH but it's not tied to it and can happily use PuTTY if told to do so. Everyone can pick their choice here. I think that if PuTTY is installed in the system or used by some other tool (looks like your case) making Git use PuTTY is a natural choice then.

Community
  • 1
  • 1
kostix
  • 51,517
  • 14
  • 93
  • 176
  • 1
    One (serious) caveat when using PuTTY with Git for Windows though: when connecting to yet unseen host for the first time it would want to ask the user to accept that host's key fingerprint -- see [this issue](http://code.google.com/p/msysgit/issues/detail?id=96). The solution is to first connect to that host using PuTTY by hand (either via its GUI client or by running `plink.exe`. – kostix May 10 '12 at 07:17
  • The question this duplicates doesn't seem to explain *how* to set Git up to use `plink.exe` as its SSH agent. Do you have any pointers, please? :) – Owen Blacker Jun 04 '13 at 16:26
  • 1
    @OwenBlacker, sure -- follow [this guide](http://nathanj.github.com/gitguide/index.html). Also please don't mix the terms: `plink.exe` is an SSH *client,* which might (or might not -- but it does that by defaut) contact a running SSH *agent* which is implemented by a program called `pageant.exe` in the PuTTY suite. – kostix Jun 06 '13 at 15:38
  • 1
    @OwenBlacker, the whole idea of an SSH agent is to cache decrypted SSH keys first asking you for a password to decrypt each key you throw at the agent. An SSH client then tries to contact the agent and ask it for the keys it has to try to authenticate with them on the server. This way you only type the passphrase for each of your SSH keys once per login session (or, rather, once per agent run time). – kostix Jun 06 '13 at 15:40
  • 2
    @OwenBlacker, one minor note re. the guide I referred to. The Git for Windows installer does only ever show you the page to pick the preferred SSH client if it finds in the registry saved SSH sessions maintained there by PuTTY. So if you don't have any, you won't have a chance to pick `plink.exe` in the installer. If this is the case, just add an environment variable `GIT_SSH` and set it to the full pathname of the `plink.exe` binary. – kostix Jun 06 '13 at 15:44
  • Ah, splendid, thank you, kostix. (I was aware that `pageant.exe` is the SSH agent, as I use it already with PuTTY and TortoiseGIT, but I wasn't quite sure what `plink.exe` is, as I've never used it, so I used the terms in your answer. I'm still slightly confused by that, but I'll take a look when I get into the office tomorrow morning.) Thanks! :o) – Owen Blacker Jun 06 '13 at 21:59