I want to configure my SSH client to work with different keys when pushing to GitHub, with one key being the "default".
I thought that putting this into .ssh/config
will give me what I need:
Host github-foo
HostName github.com
IdentityFile ~/.ssh/id_rsa_FOO
Host *
IdentityFile ~/.ssh/id_rsa_BAR
according to man ssh_config
, when git is connecting to a remote with url git@github-foo:myuser/myproject
, ssh should take the first value of IdentityFile form matching Host
blocks (~/.ssh/id_rsa_FOO
in this case) and use it. However, ssh is authenticating with the id_rsa_BAR
key. What am I doing wrong? Is this a bug?
I've read this, but that solution requires changing every remote repo url; there is no "default" key in that approach. I would like to be able to leave the url unchanged for all repos that should use the "default" key (id_rsa_BAR
in this example).