Failed to connect with SourceTree over SSH
Asked by Thomas Herchenroeder:

On Windows7, using SourceTree 1.6.20 I cannot connect to the remote server over SSH. Fetch, pull, etc. fail. Neither OpenSSH nor Putty/Plink in the Client SSH Configuration works. (Everything is fine with Git from the command line).

With OpenSSh, the CMD prompt for my passphrase opens and closes immediately, without any chance to actually enter the passphrase (This used to work on my old machine with the same key pair).

With Putty/Plink, I'm presented with a server SSH fingerprint which I cannot accept (as it is only in the "Show Full Output" dialog which is not interactive).

Running Plink directly on the command line offers a different fingerprint, so accepting this has no effect on the SourceTree behavior.


Answers:
author: rrudnicki
body: Hi Thomas,

Did you checked this configuration? <https://confluence.atlassian.com/bitbucket/how-do-i-use-ssh-with-sourcetree-282173660.html>

Also are you getting some error or the cmd prompt just close?

In case you still face issues, raise a ticket with us :smile:

Regards,   
Renato Rudnicki

comments: author: Thomas Herchenroeder
body: Hi Renato,Thanks for getting back. - I went again through the steps of the link you provided. Once I entered the repository source URL and tab to the destination path, I get this error:"The OpenSSH agent is running but the server still rejected your connection. You may need to add the correct key to your agent by selecting Tools \> Add SSH Key. ..."Let me say that at this point I had already added my private SSH key alright.(This is also the error message I get when pulling/pushing on a repo that I added from a local working copy.)Choosing "Close" on the error dialog leaves me with the "Clone / Add / Create Repository" dialog, where the Repository Type field is set to: "? This is not a valid source path / URL". Clicking the associated "Details..." button opens another message window saying:"Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists."-----As for the cmd prompt, it flashes by so fast that I cannot say if it contains an error message or not. Is there anyway to make it stay open?I'll open a ticket, and will link to this question.Thanks,Thomas


author: Maik Hoffmann
body: Hi,

I got the same problem. If I want to push or pull to/from my external (2nd) repo the program does not ask for login/password. Just present:

```
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream Home-CB master:masterPushing to ssh://xxxx.ddns.net/home/xxxx/repos/ThxxxFATAL ERROR: Server unexpectedly closed network connectionfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
```

With pure git-bash and tortoise-git it works.

And NO I don't want to use public-key for several reasons.   

comments: author: Tim Boundy
body: That's not the same problem, the OP is getting a password prompt but it vanishes immediately, and they're getting SSH fingerprint issues, depending on which method they use. You're just not getting any password prompt at all, with no SSH fingerprint issues. I am however getting the same issue as you. No password prompt, SourceTree just fails with the "FATAL ERROR: Server unexpectedly closed network connection" after the server drops the connection because no password was provided after some timeout. TortoiseGit and Git Bash both work fine for me too.


author: childnode
body: it's a bug to me. just open Putty once and try to connect to the host via ssh. Yes this mostly won't work since you don't have complete shell access on most git hosts but putty will prompt you for the same message confirmation.

Accept it, switch back to SourceTree and: happy fetching


author: Rahul Agarwal
body: I have the same issue. It used to work fine for me but does not work since Win 10 update. I have installed the latest Source Tree. I think the cmd prompt to enter passphrase does appears briefly but disappears before I can enter it.

Git bash is all good.

comments: author: Thomas Herchenroeder
body: Try starting SourceTree from the Git bash (rather than desktop icon, start menu, etc.).


author: Libor Nenad?l
body: No change, does not work either.


author: Thomas Herchenroeder
body: @Libor Nenad?l The ticket status is "Closed, resolved with existing knowledge". The solution was what I wrote in my comment to Rahul: Start SourceTree from a Git Bash prompt (you might have to specify the complete Path to the SourceTree executable). Then the ensuing command prompt for your passphrase stays open and the passphrase can be entered.


author: Libor Nenad?l
body: What is the ticker status? When I try to access the URL it says: "You do not have permission to view this request." ![sad](/html/@C495B4504065515364EB1894F812B34C/images/emoticons/sad.png "sad")


author: Thomas Herchenroeder
body: Here is the corresponding ticket over at Atlassian Support: <https://support.atlassian.com/servicedesk/customer/portal/1/STSP-2437>

comments: author: Jim_Hobday
body: That link is broken