Using Multiple SSH Keys for Access Different Git Accounts

At work, I use both my companies internal GitLab and my personal GitHub account.  This requires multiple ssh keys for accessing each respective account.

Under Linux, this requires a ~/.ssh/config file, with a similar setup to the following:

 

Host github.com
User jonathan
IdentityFile ~/.ssh/id_rsa_github

Host *
User jonathan
IdentityFile ~/.ssh/id_rsa

 

In the above, I have a specific key for my GitHub account and a default key which I use to service my company’s internal GitLab.  This behaviour overrides the settings in the default ssh_config file.  There are various other parameters configurable as required.

  • Port
  • Protocol
  • LocalForward

 

The man pages are very helpful in this regard.

 

Helpful Resources:

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.