I have multiple ssh config folders for various systems e.g.:
ssh -F ~/.ssh/system-a/config user@system-a
ssh -F ~/.ssh/system-b/config user@system-b
Each folder has a config file and set of identity files like so
Host system-a
HostName <some_hostname>
User <some_username>
IdentityFile ~/.ssh/system-a/keys/system-a.pem
How do tell git to use a certain ssh config file or a certain ssh key when performing git tasks?
Ideally I would like to do this per git project if I can.
As Andrejs Cainikovs and Jakuje have pointed out, it is possible to use multiple ssh-config files with a recent enough
git.However, you can achieve virtually the same results with a single ssh-config file with multiple configurations, possibly all referring to a single real host:
and then clone the repos like:
This will use
<some_username>@<some_hostname>with the ssh-key in~/.ssh/system-a/keys/system-a.pemfor thebarrepository, whereas it will use<other_username>@<other_hostname>with the ssh-key in~/.ssh/system-b/keys/system-a.pemfor thefrobnozzelrepository.