Using Multiple SSH Keys at the same time - GitHub, BitBucket, etc.

Whenever I move to a new computer I setup access to my GitHub account, BitBucket, GitLab, etc. For each I create a new SSH key, and upload to the respective sites.

Then I forget how to store them properly on my local computer so that I can easily connect to those services, it usually takes my 15 or 20 minutes to find an example, and each time I promise myself I’ll write it down next time. Well here it is…

Generate the keys

This post is not about generating the keys, each of the sites will have suggestions on how to do that, and the type of key to create. But you will want to give each a unique name.

They will then be stored in your_home_directory/.ssh.

In my case I have -


Create a config file

Add a file named config (no extension).

Its format is very important, that one space at the start of the second and fourth lines is necessary.

 IdentityFile ~/.ssh/bitbucket_id_rsa
 IdentityFile ~/.ssh/github_id_rsa 

That’s it, next time I need to figure this out I’ll know where to come!

comments powered by Disqus