Using multiple SSH keys for Github and Github enterprise

06 Feb 2023

Using multiple SSH keys for Github and Github enterprise

less than 1 minute read

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, :heart: 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

Start a conversation about this content on Reddit or Hacker News.