It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
 HostName bitbucket.org
 IdentityFile ~/.ssh/id_rsa
# Default address: 	git@bitbucket.org:accountname/reponame.git
# Alias address: 	git@<Host>:accountname/reponame.git
# Usage:                git@myhostname:accountname/reponame.git

Host somethingelse
 HostName bitbucket.org
 IdentityFile /var/www/id_rsa.something
# Default address: 	git@bitbucket.org:accountname/reponame2.git
# 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.

~/.ssh/id_rsa
/var/www/id_rsa.something

The keys above are associated to bitbucket.org. 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,
Rafael

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted Jan 17, 2019 in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going.  The ...

1,431 views 13 14
Join discussion

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