Skip to main content

Using multiple SSH keys for Github and Github enterprise

·1 min
Ssh Terminal Tips
Table of Contents

Looking to configure multiple SSH keys on the same computer? For instance to use a different SSH key for your public and enterprise Github contributions.

This quick little post will show you how to do that.

Steps
#

In this I’m assuming you already have an SSH key setup for your enterprise Github account.

  1. Create a new SSH key and add it to the ssh-agent
  2. Update your ~/.ssh/config file and add a new host:
Host *
  AddKeysToAgent yes
  UseKeychain yes

Host github.com
  IdentityFile ~/.ssh/id_github_rsa
  UseKeychain yes

Host github.mycompany.com
  IdentityFile ~/.ssh/id_rsa
  UseKeychain yes

I’m explicitly defining each host, but you could also assign a SSH key to all remaining hosts using Host *.

That’s it!

This site is 100% tracker free, ❤️ for liking my post on Mastodon or Linkedin to let me know you’ve read this.

If this was helpful to you, consider buying me a coffee.

Jeroen Mols
Author
Jeroen Mols
Jeroen Mols is a Google Developer Expert (GDE) in Android, the former lead Android developer at Philips Hue and an internationally recognized speaker. He is currently pushing his boundaries as a full stack developer at Plaid.