I am trying to set up multiple ssh keys for two different github accounts but I can't seem to get it to work like I'd like.
Currently I have two ssh keys, we'll call them a_rsa
for repos cloned from github.com-a and b_rsa
for repos cloned from github.com-b.
I'm on Ubuntu and all my keys and config are located in ~/.ssh
. My ssh config looks like this:
#Account A
Host github.com-a
HostName github.com
User git
IdentityFile ~/.ssh/a_rsa
#Account b
Host github.com-b
HostName github.com
User git
IdentityFile ~/.ssh/b_rsa
and an example url in one of my .git/config
files is:
url = git@github.com:a/SomeRepo.git
No matter which repo I am in when I try to push or pull from master it always tries to use key b_rsa.
I have tried changing the User on each to a
and b
respectively to no avail. I'm not sure if my config is even being read as I have tried setting my config file to just this:
Host *
IdentityFile ~/.ssh/a_rsa
And all my repos still try to use the b_rsa
key.
The way I would like it to work is based on the owner of the repo I am tyring to push to (owner a
or b
) it would use the appropriate key but I can't seem to figure out what is wrong.