Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TortoiseGit using incorrect SSH key

Tags:

I have a strange problem with tortoise git at the moment, which I can't figure out. When trying to commit to my repository on github I get the error

ERROR: Permission to martindevans/Hermes.git denied to key2

Key2 is a key I use to access a different github repository, however the remote url is not set to use key2, as you can see here it's set to use private.ppk

enter image description here

Am I doing something obviously wrong, or is tortoise git broken?

Nb. In response to the comments. Using normal git results in:

C:\Users\Martin\Documents\Visual Studio 2010\Projects\Hermes>git push Permission denied (publickey). fatal: The remote end hung up unexpectedly 
like image 565
Martin Avatar asked Mar 18 '11 23:03

Martin


People also ask

What is signing key ID in TortoiseGit?

The idea is: 1) You generate a keypair, 2) You export your public key and register it with your GitHub account, 3) You register it in your local Git configuration as "key id". Subsequent commits will be signed with that key. – paulsm4.

Is Git and TortoiseGit same?

TortoiseGit is a Git revision control client, implemented as a Windows shell extension and based on TortoiseSVN. It is free software released under the GNU General Public License.


2 Answers

There are different private key formats. My keypair was generated with puttygen, but my Tortoise was configured to use ssh.exe (form msysgit) as ssh-client. So i changed it to plink (from Tortoise) and it worked.

  • ssh-key.exe => ssh.exe (C:\msysgit\msysgit\bin)
  • puttygen.exe => TortoisePlink.exe (C:\Program Files\TortoiseGit\bin)

Additional note: Use the correct URL! Github offers you three URL https, git and ssh.


Edit:

I adapted the settings here:

Settings - TortoiseGit >> Network >> SSH-Client C:\Program Files\TortoiseGit\bin\TortoisePLink.exe 

I have generated the key-pair with:

 C:\Program Files\TortoiseGit\bin\puttygen.exe 
like image 107
Doomjunky Avatar answered Oct 05 '22 07:10

Doomjunky


Hah! ProcMon to the rescue. This is a bug in tortoisegit / tortoiseplink. It should give preference to the key set for that remote via pageant, but instead it gives preference to the key stored in the registry by putty for that specific server. Two fixes.

2 possible fixes here

Your tortoiseplink is integrated with putty, and it's reading the private key you have saved in the putty "Session" associated with that server. At least that's what it was for me. I'm not on github though, so I don't know the viability of this solution for everybody.

I'd recommend deleting the key set manually in the putty session configuration and using pagaent for your putty sessions, as that's what tortoise git does. This also makes tortoisegit use the key set for the remote.

  1. So, you can open up putty, load whatever session you have associated with the server, go to the Connection/SSH/Auth and modify / remove the "Private key file for authentication" value. MOdification may fix this repo but then screw up another repo if you are using different keys for the same server.

  2. You can modify / delete the registry entry yourself. it's HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\$SERVERNAME$\PublicKeyFile

like image 28
scaryman Avatar answered Oct 05 '22 06:10

scaryman