SSH keys and GitHub

Use a specific SSH key for a Git repo

Make Git use a particular SSH key, for one command or for one repo, instead of your default key.

Fill these in once
  1. For one command
    Terminal
    GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_work -o IdentitiesOnly=yes" git clone git@github.com:company/project.git
  2. For this repo from now on (inside the repo)
    Terminal
    git config core.sshCommand "ssh -i ~/.ssh/id_ed25519_work -o IdentitiesOnly=yes"
  1. For one command
    Terminal · Ubuntu / Debian
    GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_work -o IdentitiesOnly=yes" git clone git@github.com:company/project.git
  2. For this repo from now on (inside the repo)
    Terminal · Ubuntu / Debian
    git config core.sshCommand "ssh -i ~/.ssh/id_ed25519_work -o IdentitiesOnly=yes"
  1. For one command
    PowerShell
    $env:GIT_SSH_COMMAND = "ssh -i $env:USERPROFILE\.ssh\id_ed25519_work -o IdentitiesOnly=yes"; git clone git@github.com:company/project.git
  2. For this repo from now on (inside the repo)
    PowerShell
    git config core.sshCommand "ssh -i ~/.ssh/id_ed25519_work -o IdentitiesOnly=yes"