Connecting to remote Git via SSH fails - SourceTree sends wrong username
Asked by David E. Smith:

I'm trying to connect to a remote Git repository, which is only accessible via authenticated SSH. SourceTree is unable to connect, always returning messages about failed authentication.

Upon reviewing the SSH logs on the server, the issue appears to be that SourceTree is sending the wrong username. Instead of sending the username I've entered, it always send my local username (my username, on my local Mac).

Here's a snippet of SSH logs from the Git server:

Sep 7 09:17:02 wuis7802 sshd 4153 : Invalid user davidsmithlocal from 1.2.3.4

Sep 7 09:17:02 wuis7802 sshd 4154 : input_userauth_request: invalid user davidsmithlocal

Sep 7 09:17:02 wuis7802 sshd 4153 : Failed none for invalid user davidsmithlocal from 1.2.3.4 port 50006 ssh2

Sep 7 09:17:02 wuis7802 sshd 4153 : Failed password for invalid user davidsmithlocal from 1.2.3.4 port 50006 ssh2

Sep 7 09:17:02 wuis7802 sshd 4153 : Failed password for invalid user davidsmithlocal from 1.2.3.4 port 50006 ssh2

Sep 7 09:17:02 wuis7802 sshd 4154 : Connection closed by 1.2.3.4

(I've changed my IP but nothing else. Yes, on my local machine, my user name actually is 'davidsmithlocal'. I didn't pick it...)

There will be several instances of the above, repeated, as SourceTree tries to log in several times before failing. This problem exists whether I try to log in using a normal user account, root, or a Windows domain account; all can log in via SSH normally.

This appears to be a bug. Any suggestions for a workaround, or ETA on a bugfix?


Answers:
author: David E. Smith
body: The user gave up on using this software. (I'd close this question, but I actually don't have permissions to do so. Any passing mods, feel free to do so.)

Edit: No moderators in sight. I've flagged this as an answer (it isn't, but that way Atlassian will stop emailing me about every day).

comments: author: JustinWJahn
body: I had similar problem or was getting error message authentication with SSH keys failed. Did not realize that the key needs to be saved on GitHubs side as well.

going into settings then 'SSH and GPG' keys then copying and pasting and saving the key generated from Putty solved the problem

Simple but when you don't know..... actually had to dig quite a bit to find that.


author: lbarbisan
body: \<cite\>I had such issue also,  

I usually use ssh.exe provide by git distribution, for some reason SourceTree rely on putty which have is own private key format (.ppk).  

To make it works I took my private key (id_rsa) convert it into ppk (id_rsa.ppk) using menu :  

1. Tools=\>Create or Import SSH key, Then click on Load Button and load the private key (id_rsa).  
2. Click on "Save private key" as id_rsa.ppk  
3. Then got to Tools =\> Option, under ssh key field set the new ppk.  

Note :  
you need to connect to your repo with your username : ssh://username@repo-git/myrepo  
I'm not using default ssh deamon here, but the gerrit one.  
This doesn't work with submodule referenced without username...\</cite\>


author: Patrick Horn
body: I have the same problem. I tried to use SourceTree and GIT for the first time, I need to access to a remote repository with SSH authentication (they have my public key, I have my private key), and I have a valid url (syntax git@git.xyz.de:xyz.de), I entered it with and without prefix "ssh://".

I always get the message: "This is not a valid source path / URL".

The I tried the same with "SmartGit" and it worked at once ... but I would prefer to use SourceTree ....

:-(

comments: author: Mikko Hyv?rinen
body: I have this same problem. SourceTree cannot clone anything via SSH from our gitolite server, the message is always "This is not a valid source path / URL". Server logs show no access attempt so this may be something going wrong already on the client end.


author: Scott Lavender
body: Have you tried setting the user global Git user?

git config --global user.name "myusername"


Tags: git