Hi

I have 2 github accounts with different ssh keys. I have reconfigured my .ssh/config to use my rburgst account on github, however, when I try to clone a private repo using it always tries to use id_rsa rather than id_rsa_github.

see my .ssh/config file below

Host github.com

User rburgst@email.com

Hostname github.com

IdentityFile ~/.ssh/id_rsa_github

2 answers

1 accepted

Actually, the Host and HostName of the original post are the correct ones:

Host public-github
        HostName github.com
        User yourown_username
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_github_pub
        IdentitiesOnly yes

I think your config file is incorrect, you've mixed 'Host' and 'Hostname' with the same setting, they need to be different. Also your user name looks wrong, it will need to be your GitHub user name and not your email (I know that GitHub lets you log in with your email, but that's not the actual name of your account, and that's what SSH uses).

Try this:

Hostname GitHub1
Host github.com
User your_github_account_name_not_email
IdentityFile ~/.ssh/id_rsa_github

Hostname GitHub2
Host github.com
User your_github_account2_name_not_email
IdentityFile ~/.ssh/id_rsa

Then when you use the host, you use the friendly host name (GitHub1, GitHub2) as host aliases to these configurations instead of github.com.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Jodi LeBlanc
Posted Thursday in Off-topic

Friday Fun: How do you recharge your batteries after a busy week?

Happy Friday – Fun Day! I don’t know about you, but I have been giving everything I’ve got this week (and most weeks) and come Friday I look for unique ways to recharge my batteries - rest, relax, a...

215 views 21 4
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