19

I am having trouble getting git/tortoisegit to use my supplied ssh key (created using PuttyGen). In the command prompt I get a permission denied error, and in the TortoiseGit UI I get prompted for a password. I tried this SO question, but as stated, I created with PuttyGen, have Pageant running with my keys loaded, and am configured to use TortoisePlink.

I then found this SO question, and tried to use the ssh in the git directory, the TortoisePlink in my TortoiseHG (used for Bitbucket/Mercurial), and as stated, had already tried the local TortoisePlink in TortoiseGit.

Oh, and I did set up my ppk in my Git account, as well as, in the Git->Remote section of TortoiseGit

So, what am I missing?

Community
  • 1
  • 1
Justin Pihony
  • 66,056
  • 18
  • 147
  • 180

7 Answers7

15

Check what your origin url is.

Right click on your project folder TortoiseGit -> Settings -> Choose Git -> Remote and select the origin entry.

Check that the url starts with ssh:// and that your private key is loaded.

If the url starts with https:// then it will ask you for your password every time.

Hope this helps.

Bohdan Kuts
  • 607
  • 15
  • 23
CGRobinson
  • 167
  • 1
  • 2
  • This didn't quite work for me. I actually had to remove the protocol., i.e., not have `https://` OR `ssh://` in the URL. – beldaz Nov 20 '15 at 23:31
  • @beldaz: If I try that (neither `https://` nor `ssh://`), I get *... does not appear to be a git repository fatal: Could not read from remote repository.* – O. R. Mapper Dec 30 '15 at 00:43
  • This solution doesn't work for me. I am getting the message: *Disconnected: No supported authentication methods available (server sent: publickey)* – O. R. Mapper Dec 30 '15 at 00:47
  • @O.R.Mapper: Not sure why that is, sorry - I just double checked and my setup is working fine. Only thing I can think of is if you don't have the Putty Key field set. Or maybe you have credentials set elsewhere that conflict... Sorry not to be more useful. – beldaz Jan 05 '16 at 23:40
  • @beldaz: I think it was caused by the issue I meanwhile found and described in [a separate answer](http://stackoverflow.com/a/34521460/1430156). – O. R. Mapper Jan 05 '16 at 23:44
  • I didn't have `ssh://` in my URL but I noticed that my key path was missing for some reason. Once I put that back in, everything worked. – The Unknown Dev Jan 09 '17 at 18:38
  • didn't work for me either until I put my user name in the ssh string. i.e. ssh://@ and for the putty key, I had the path to my private key which needs to be in puttygen format. See this link about puttygen (https://the.earth.li/~sgtatham/putty/0.67/htmldoc/Chapter8.html#pubkey-puttygen) I know this is old but hope this helps someone – Eric Feb 04 '17 at 05:03
5

Some Git servers are somewhat counterintuitive (IMHO) when it comes to authentication. For instance, Github docs say:

All connections must be made as the "git" user.

So, instead of trying to connect to ssh://<yourname>@github.com..., you have to connect to ssh://git@github.com....

I am not asked for a password any more and TortoiseGit now shows Success after completing a Push operation.

O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
4

I could not make this work with github/tortoisegit either. Using git from the command line on linux worked fine. I then resorted to using my username/password as described here:

http://www.programmoria.com/2012/02/saving-tortoisegit-password.html

and elsewhere. It is not a real solution (sorry) but a workaround that achieves the same thing: automatic authentication without having to enter your username/password. The _netrc file is as secure/insecure as the private key that would also be stored somewhere on your computer so I consider it an acceptable solution. Comments on this are welcomed of course.

Sander P
  • 41
  • 2
  • 1
    I don't think it is as secure as using a private key file, since I can protect the latter with a password and there is nothing in clear text. – Martin Ender Nov 28 '12 at 22:05
  • SSH is not clear text. Also, requiring a password to open your private key is no easier than just using a password directly. – DDS Jul 31 '14 at 21:22
1

Does your account on the OpenSSH server know you should be authorized with your public key?

Load your key with PuTTyGen. You will see a read-only textarea under "Public key for pasting into OpenSSH authorized_keys file". Copy what's in there.

SSH with PuTTy into the SSH server. Open up the ~/.ssh/authorized_keys file with an editor and paste the copied text in a new line and save. The ~/.ssh directory may not exist yet. In that case, do mkdir ~/.ssh before editing that file.

Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64
1

I was also facing the same problem on v1.8.4, then I switched my ssh client to plink and its working fine now. TortoiseGit Settings -> Network -> SSH client

plink is distributed along with peagent and other goodies in standard putty package

Apparently there is a bug in certain versions of TortoiseGit (TortoisePlink in particular) see this answer

Community
  • 1
  • 1
mzzzzb
  • 1,422
  • 19
  • 38
  • By using plink, I get the message *fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.* (Unless I am misinterpreting what the Github web interface tells me, I am sure about all of these.) – O. R. Mapper Dec 30 '15 at 00:51
0

I am using git 2.7 and tortoisegit 1.8.16 Here is what I did to avoid requiring password and it worked for my case

Right click on your project folder TortoiseGit -> Settings Choose Git -> Remote and select the origin entry Change url from https://github... to ssh://git@github...

Tue
  • 3
  • 2
0

Using Tortoise 2.2.0.0, you need to do a couple of things. On the remote tab, you can either remove the http(s) origin you already have or you need to add a second, using ssh:// and checking the "Push Default" checkbox for the ssh one so that Tortoise uses it for pushes by default (and the https origin in my case for pull).

Only the ssh one needs the key specified and then when you Push, it should default to your new ssh origin as the destination and not ask for your username and password.

Obviously you need to know what user to have in your URL. For example, in Visual Studio Team Services, it is the name of the VSTS account (not account holder!). You might also need the port number.

That's all I did to setup from scratch and it worked fine.

Lukos
  • 1,826
  • 1
  • 15
  • 29