I am trying to understand how the configurations in .ssh / config and .git / config interact.
Here's the situation: I have two separate github accounts, let them call them GH0 and GH1, and I want to interact with both without a password, that is, using the ssh keys in ~/.ssh/id_rsa.GH0.pub and ~/.ssh/id_rsa.GH1.pub . Currently this works for GH0, but not for GH1. (For example, the push commands for GH1 die with ERROR: Repository not found.\nfatal: The remote end hung unexpectedly. .; ssh -T git@github.com works, but only because it connects GH0 .)
This means that for each of these github accounts I should have a corresponding section in ~ / .ssh / config, indicating which ssh key file to use for it. (For example, the section for GH0 will have something like IdentityFile ~/.ssh/id_rsa.GH0 , etc.)
Question: what else do I need to insert into each of these sections? More specific,
What do I need to put as an argument to the Host keyword in ~/.ssh/config ?
The information that I have found so far makes no sense to me. In some examples, I see things like
Host github.com Hostname github.com User git IdentityFile ~/.ssh/id_rsa Host ac2.github.com Hostname github.com User git IdentityFile ~/.ssh/id_rsa_ac2
Where is this "ac2". the prefix in the second Host comes from
Where can I find the appropriate ones for my github accounts?
Some of the information I found suggests that the Host keyword arguments are actually arbitrary, implying that the following will be fine too
Host omgwtfbbq Hostname github.com User git IdentityFile ~/.ssh/GH0 Host 4.8.15.16.23.42 Hostname github.com User git IdentityFile ~/.ssh/GH1
But if so, another question arises: How does git (or github) know which of these two sections to use for any given command?
Again, I think 1 that this will be indicated in the .git/config project file in the [remote ...] section, but how?
1 I have to resort to guessing, because, on the one hand, I could not find the documentation for interpreting key-value pairs in .git / config. The closest I found the manual page for git-config, but I can not find the documentation on this page for the url = ... field in the [remote ...] section. The manual page for git -remote also does not have documentation for this field.