Today I learnt ...
2023-01-09T19:38:34+00:00
As a consultant with two different clients, and two different GitHub users, with their own ssh keys, how can we
git push
?
If the user and hostname are the same but you must user a different SSH key:
-
Set up the
~/.ssh/config
file as followsHost github-as-client1 HostName github.com User git IdentityFile ~/.ssh/id_ed25519.client1 IdentitiesOnly yes Host github-as-client2 HostName github.com User git IdentityFile ~/.ssh/id_ed25519.client2 IdentitiesOnly yes
-
Instead of the real hostname, use the following in your
git remote
# client 1's repo git remote add origin git@github-as-client1:your-repo.git # client 2's repo git remote add origin git@github-as-client2:your-repo.git