GitSSH

13th November 2016 at 8:35pm
Git OpenSSHTipsAndTricks SSH

You have a few different options open to you if you want to tell your git client to use a specific SSH private identity key, or pass myriad other SSH arguments.

~/.ssh/config

Firstly you could simply add a host entry your ~/.ssh/config file for the specific remote git server.

Host github.com
  IdentityFile ~/.ssh/id_rsa_github
  User git

GIT_SSH_COMMAND

Git version 2.3.0 or newer supports the GIT_SSH_COMMAND environment variable.

GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_github" git clone git@github.com:MyGithubUser/repo.git

core.sshCommand

Git version 2.10.0 or newer supports setting the core.sshCommand option either per repo or globally.

git config core.sshCommand "ssh -i ~/.ssh/id_rsa_github"
git clone git@github.com:MyGithubUser/repo.git

GIT_SSH

GIT_SSH environment variable.