Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

SourceTree on Windows can't connect to GitHub using OpenSSH

Nitzan Shaked April 8, 2014

(Running Windows 7, SourceTree 1.5.1.0 configured to use OpenSSH)

When my private key (stored in C:\Users\MyUser\.ssh) is called id_rsa everything works fine: I can clone GitHub repositories, pull, etc., using regular GitHub URLs: git@github:my-github-user/my-repo.git.

But when I rename my private key to something else and let SourceTree know about this (under Tools -> Options -> SSH Key) it fails to connect.

Furthermore: if I create C:\Users\MyUser\.ssh\config and add something like

Host github2
 Hostname github.com
 User git
 IdentityFile something_else 

And try URLs such as git@github2:my-github-user/my-repo.git or ssh://github2/my-github-user/my-repo.git, it doesn't work.

It's as if OpenSSH in SourceTree is hardwired to read only id_rsaand ignore other settings (such as .ssh\config and/or SSH Key).

Ideas?

2 answers

1 accepted

1 vote
Answer accepted
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2014

I am using a private key other than id_rsa, but my configuration is completely different than yours.

First of all, I am not using .ssh to store my key or for any manual config.

Secondly, I am not specifying a specific key in SourceTree options.

Thirdly, I am using Pageant as my key agent, which I DO have set in my SourceTree config. I have Pageant configured to load the key at startup. It seems that SourceTree simply tries to authenticate with any keys in Pageant.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2014

Also, Rafael's instructions seem tailored for Mac/Linux, which isn't going to be particularly helpful since you said you're on Windows.

Nitzan Shaked April 26, 2014

That's interesting, I'll check it out. I was still hoping to understand why OpenSSH (no agent) doesn't work, though.

Nitzan Shaked May 2, 2014

Well it works. Unfortunate that I couldn't find any other solution, but for the sake of good order I'll accept this answer.

1 vote
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 10, 2014

Hi Nitzan,

Create a SSH config file

When you have multiple identity files or a ssh key different from id_rsa, create a SSH config file mechanisms to create aliases for your various identities. You can construct a SSH config file using many parameters and different approaches. The format for the alias entries use in this example is:

Host alias
HostName bitbucket.org
IdentityFile ~/.ssh/identity

To create a config file for one identity different from id_rsa or two identities+ (workid and personalid), you would do the following:

  1. Open a terminal window.
  2. Edit the ~/.ssh/config file.
    If you dont have a config file, create one.
  3. Add an alias for each identity combination for example:
    ## Sample 1
    Host defaultid
     HostName bitbucket.org
     IdentityFile ~/.ssh/id_rsa
    
    ## Sample 2
    Host customid
     HostName bitbucket.org
     IdentityFile /Users/user/Downloads/customid
  4. Close and save the file.

Now, you can substitute the alias for portions of the repository URL address as illustrated below:

## Sample 1
# original command
git clone git@bitbucket.org:accountname/reponame.git

# will become
git clone git@defaultid:accountname/reponame.git

## Sample 2
# original command 
git clone git@bitbucket.org:accountname/reponame.git

# will become
git clone git@customid:accountname/reponame.git

Load each key into the appropriate Git account

You load each identities public key into corresponding account by copying id_rsa.pub and/or customid.pub content and paste it into individual SSH key fields (Deployment keys).

Ensure the ssh-agent is loaded with your keys

List the currently loaded keys:

$ ssh-add -l
2048 32:ad:d1:3c:4b:3b:f4:34:7a:c5:b2:4a:be:8e:d8:9a /Users/user/.ssh/customid (RSA)
2048 68:ef:d6:1e:4b:3b:a3:52:6f:b0:c3:4b:da:e8:d1:9f /Users/user/Downloads/customid (RSA)

If necessary, add your new key to the list:

$ ssh-add /Users/user/Downloads/customid
Enter passphrase for /Users/user/Downloads/customid:
Identity added: /Users/user/Downloads/customid (/Users/user/Downloads/customid)

Kind regards,
Rafael

Nitzan Shaked April 26, 2014

Rafael -- kindly *reread* my question. You'll notice I did just that, but to no avail. I also made a specific comment re ssh-agent.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2014

Those don't look like Windows instructions.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events