72

I Generated ssh keys and configured my git and SourceTree. I could git pull and do other operations from Git-bash. Note: I have added the following in .bashrc to make it work.

eval `ssh-agent`
ssh-add

However, when I try to git pull in SourceTree, I get this.

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin Permission denied (publickey,password). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

When I tried to create ssh-key from Putty(windows), it goes further, but waits with this following message!

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is:

ssh-rsa 2048 0f:ee:bb:1c:6c:b4:50:0e:54:d6:e9:55:9b:38:45:df If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection.

if I open the terminal in SourceTree(which is git-bash), it asks me for passphrase. So, i suspect my .bashrc is not sourced by SourceTree. Or am I missing something else?

Kenster
  • 23,465
  • 21
  • 80
  • 106

6 Answers6

148

I changed the client configuration from putty to openssh.

Go to: Menu Tools > Options > SSH Client

enter image description here

Andrew
  • 6,808
  • 3
  • 18
  • 33
AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277
98

I had the same problem and the solution for me was to call plink.exe manually with my server (GitLab):

"C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe" gitlab.com

Press y when asked and you should be fine now!

JPelletier
  • 2,049
  • 16
  • 23
  • 1
    It asked login/and password. What to do? I use rsa key. – May12 Nov 13 '15 at 06:29
  • 7
    @May12: no password is required at this stage. Just hit "y" to store the key in cache. Then return to SourceTree and you should no longer see the error. – SaeX Nov 19 '15 at 15:55
  • 2
    Thanks!! it would be nice to know why source tree cant to this by itself!!! or popup a screen where it ask about! – tyoc213 Feb 08 '16 at 18:31
  • 2
    Worked great, i have a specific port also which required setting with the -P option. – Mårten Feb 29 '16 at 13:38
  • Worked for me too using `plink bitbucket.org` from my git bash in windows. Thank you! – haakym Mar 13 '16 at 12:56
  • 1
    In my case the server wants me to authenticate but does not accept the private key... – Azimuth Mar 16 '18 at 10:28
  • same for azure `plink.exe ssh.dev.azure.com` then typing "yes" then Ctrl+C there you go putty will trust the host and won't ask on the sourcetree GUI – Jose Velandia Mar 08 '23 at 18:51
15

I was able to fix the problem by changing from "Putty/Plink" SSH to "OpenSSH" for the SSH provider.

Menu Tools > Options then SSHClient, select OpenSSH
luchopintado
  • 899
  • 11
  • 15
5

The best solution is to get a connection using Putty.

On the Host Name, put your gitlab project ssh address. then, click 'Open' to connect.

That's it. SourceTree trust gitlab.com after all. you may check the solution from the below link. https://answers.atlassian.com/questions/31659457/windows-7-64bits-sourcetree-openssh-putty-git-pull-not-working

enter image description here

wal
  • 17,409
  • 8
  • 74
  • 109
Kabkee
  • 198
  • 2
  • 11
  • also worth noting you can simply start the putty ui, type in `github.com` or `bitbucket.org` or whatever your repo is into the hostname and you'll get the screenshot above – wal Nov 10 '22 at 03:54
1

gitlab.com currently (as of 06-28-2022) has a bug where it will fail using plink / ssh.

The fix is to set the "winadj" bug fix setting in your putty configuration for gitlab.com

Image below is of the screen "Chokes on winadj" is set to "On" instead of "Auto". This fixes the problem.

enter image description here

Erik Aronesty
  • 11,620
  • 5
  • 64
  • 44
0

it's pretty complicated, but you can go to registry

\HKEY_USERS\S-1-5-21-1530211238-4060388584-3209713061-1001\SOFTWARE\SimonTatham\PuTTY\SshHostKeys and add something like rsa2@2222:127.0.0.1 as REG_SZ and server fingerprint from error, like 0x10001,0xc10790789c2f8aa97d79cbaebd1445863f6db3bb4e04236de1c3ab60e271a20da10ebc87f931a71e090a3b847cde28d0a751222f91a5c7a7f13f7d3bfa42d40b2c58a85c0667eb879b092d04706ccc6d2ec51c2ae77c08e51b2bbad425fefaf27a4e9253240809babc02e5ee93c167825311f38b15947034211db2bc50a76bd87a5f2542d30c0a09e35750ba36008aee3031efbec188fdfc8b39be3db0e01ee2ab95909e423e00c89e3da6a2bec9eed6f21dfffee9deceb5b560a5a6fa720059229e6c37a1952a4981d62fc62af2b6318057d758124c34644b6f771ab02b398043e1b5727ed22b199e943e467d0bb4b96c4689ca749cc9edb8bee028dcb9b6ef

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 10 '23 at 04:06