Johnny Matthews | Use multiple ssh-keys with Git

I’ve got multiple accounts with several different git providers. This means that I’m constantly switching betwen repos and SSH keys. Git doesn’t have a built-in way to manage multiple SSH keys, so he’s my workflow. This was written on 13th of January 2026.
  1. Create an SSH key and add the public key to GitLab/Hub/Tea/whatever.
  2. Add a Host entry in ~/.ssh/config with a custom alias, pointing to the real domain and your specific key:
# Only for `git@acme-corp:org/repo` commands.
Host acme-corp
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/acme-corp
  IdentitiesOnly yes

# Only for `git@abc-llc:org/repo` commands.
Host abc-llc
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/abc-llc
  IdentitiesOnly yes

# All other git commands (including personal ones).
Host gitlab.com
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes
  1. Use git@acme-corp:org/repo.git in clone commands:
git clone git@acme-corp:redteam9000/super-cool-exploit.git
  1. Done.