(Running Windows 7, SourceTree 220.127.116.11 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
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).
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.
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:
To create a config file for one identity different from id_rsa or two identities+ (workid and personalid), you would do the following:
## Sample 1 Host defaultid HostName bitbucket.org IdentityFile ~/.ssh/id_rsa ## Sample 2 Host customid HostName bitbucket.org IdentityFile /Users/user/Downloads/customid
Now, you can substitute the alias for portions of the repository URL address as illustrated below:
## Sample 1 # original command git clone email@example.com:accountname/reponame.git # will become git clone git@defaultid:accountname/reponame.git ## Sample 2 # original command git clone firstname.lastname@example.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)
Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs