Pageant does not load SSH-2 key generated with GitBash

Git BashPrivate KeyOpensshPlinkPageant

Git Bash Problem Overview


The implementation of key handling with (Tortoise)Git for Windows confuses me. As far as I understood, you can implement with either ssh.exe (gits own ssh program), where you can then choose an ssh key per host in your ssh_config in the 'faked' home dir. For me, that is not really applicable, because I have multiple Bitbucket accounts using different keys but all the same host.

Then there is a way to use TortoiseGitPlink. You basically set up pageant with a putty generated key and let TortoiseGit use that one - with the environment variable SSH_GIT set to your TortoiseGitPlink.exe).

Now my question is the following: I just created an ssh2 rsa key with default options using ssh-keygen -t rsa -f ~/.ssh/rsa_key command in GitBash. I tried loading this file into pageant.exe by using its GUI. I got the error: Couldn't load this key (OpenSSH-SSH-2 private key).

What is the problem with this key? Made in GitBash it should adhere all standard openSSH guidelines. Is it correct that there are differences in puTTY keys and openSSH keys?

Git Bash Solutions


Solution 1 - Git Bash

The Pageant can load keys in the PuTTY format (.ppk) only.

If you attempt to load a key in a different format, still recognized by PuTTY tools, you get the mentioned error message:

> Couldn't load this key (OpenSSH-SSH-2 private key)

You need to use the PuTTYgen to convert the key from the OpenSSH format to the PuTTY format. If the Pageant recognized the file format, the PuTTYgen can convert it.

  • Run PuTTYgen;
  • Press Load to load the private key in OpenSSH format;
  • Press Save private key to save the private key in .ppk format;
  • Now you can load the private key in .ppk format to Pageant.

Or even easier, use the PuTTYgen to create the a key directly in the PuTTY format, instead of using the ssh-keygen.


See the PuTTY wishlist for reasons it has its own key format:
https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/key-formats.html

Note that I believe there's no standard for SSH-2 private key file format.

Solution 2 - Git Bash

PuTTY doesn't understand the id_rsa private key if it shows this error: enter image description here

You need to convert the private key to a .ppk (private key format).

  1. Open PuTTY Key Generator (Start-> search 'puttygen')
  2. You will need to import the RSA private key. To do so, open the 'Conversions' menu > 'Import key'. enter image description here
  3. Select the RSA private key to convert. enter image description here
  4. Click on "Save private key". Notice that you could also save it in another format. enter image description here
  5. Then save as 'id_rsa.ppk' enter image description here
  6. Open Pageant - PuTTY authentication agent (if not already open) enter image description here
  7. Click on "Add Key"
  8. Select your converveted private key. enter image description here
  9. As you can see, PuTTY recognise it now in the 'Pageant Key List'. enter image description here

Solution 3 - Git Bash

I stillt have the problem right now. The variable SSH_GIT ist set to the TortoiseGitPlink.exe. I made a key pair with git bash

ssh-keygen -o

I loaded the key with PUTTYGen and transformed it to the *ppk version. Saved the key in the tortioseGit settings and the public key to my github account, but i still get a request to put in my credentials and afterwards my push is denied. Funny think, on my laptop it works. i am pretty sure i did everything like on my laptop.

Solution 4 - Git Bash

If you receive the error, Couldn't load private key (unrecognised cipher name), you will need to remove the passphrase from your private key before you can convert it.

Someone has written an article describing how to do this here.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionatripesView Question on Stackoverflow
Solution 1 - Git BashMartin PrikrylView Answer on Stackoverflow
Solution 2 - Git BashKeyMaker00View Answer on Stackoverflow
Solution 3 - Git BashChiburatorView Answer on Stackoverflow
Solution 4 - Git BashLarry DaVinciView Answer on Stackoverflow