Last Updated: May 03, 2017
·
366
· davewatts

Using different SSH keys for multiple git accounts

Previously, adding an SSH key for git usage has required use of the SSH configuration file, or a git environment variable. These were limited in that that you could only have one key per host (SSH) or globally (git). These limit their usefulness when using multiple accounts with github, for example

Since git 2.10, it is possible to specify a key to use in git config, and therefore on a per-repo basis.

git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"
git pull
git push

From superuser.com