Accessing different Git repositories with different accounts with SSH

It may be challenging to setup multiply SSH credentials to access different Git repositories. At least on MacOS it keeps losing which key file to use authorize against Git server. Linking it as regular in the ~/. ssh/config does not help in a long run.

Nice and bullet proof workaround is to define key file in the git repository’s config file (.git/config in a root of repository). Add these into is and all will just work:

[core]
sshCommand = ssh -i ~/.ssh/git_key_file

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Code Blog by Crimson Themes.