Using multiple SSH keys for Github and Github enterprise

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.
- Create a new SSH key and add it to the ssh-agent
- 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.
Leave a Comment