Multiple SSH keys for different accounts doesn't seem to work

SoureTree seems to choose the first SSH key in Pageant list and attempt to use that with all my repositories. This doesn't work for some which use a different key (the second one in the list).

I'm not sure how to tell SourceTree via the git config to use the second key?

1 answer

0 votes

Hi Ivan,

Have you tried to create a /.ssh/config file and add the following:

Host myhostname
 IdentityFile ~/.ssh/id_rsa
# Default address:
# Alias address: 	git@<Host>:accountname/reponame.git
# Usage:                git@myhostname:accountname/reponame.git

Host somethingelse
 IdentityFile /var/www/id_rsa.something
# Default address:
# Alias address: 	git@<Host>:accountname/reponame2.git
# Usage:                git@somethingelse:accountname/reponame2.git

Please, notice that in the sample above I have created two ssh key-pairs and I have saved them in different locations.


The keys above are associated to In order to use the correct key, please replace bitbucket.orgby the Host provided to the key you want to use. As a result, you would have:

Host myhostname -> git@myhostname:accountname/reponame.git

Kind regards,

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

230 views 0 3
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot