Using two different ssh keys for Github repositories

I have two different users at Github, one is my personal account and the other is the Uetke account. In my personal account I do sometimes play with repositories that nothing have to do with my work and therefore I like keeping things separated. However ssh keys can be used in one account at a time; fortunately the solution is easier than what I would have imaged.

First you setup your new ssh key as you probably did with the first one:

ssh-keygen -t rsa -C ""

and remember to store it with a different name than the previous one. For example I will call each key as follows:


And add them

ssh-add ~/.ssh/id_rsa_github1
ssh-add ~/.ssh/id_rsa_github2
ssh-add -D
ssh-add -l

The last two lines are just for deleting the cached files and then to list the available keys. You can verify that the proper keys were correctly installed by ssh. The last step is to modify the configuration file of ssh to enable the selection of one or the other key:

cd ~/.ssh/
touch config

Open the newly created config file with whatever editor you like and add the following:

# Github 1 account
   User git
   IdentityFile ~/.ssh/id_rsa_github1

#Github 2 account
   User git
   IdentityFile ~/.ssh/id_rsa_github2

The only thing you have to do now is to clone the repository using either or

git clone

You can also add it as a remote:

git remote add

I use this to update repositories into the Uetke profile once they are ready for the public, but in the meantime I use my personal repository for myself or extremely curious people.

Header photo by Cristina Gottardi on Unsplash

Support us
If you like the content of this website, consider buying a copy of the book Python For The Lab

Other interesting articles for you

How to Encrypt an External Drive on Linux

External drives are a great complement to laptops with a limited amount of memory. The data you generate in the lab may not fit on the SSD drive of your ultrabook, or you want to keep access to older information. Not only scientific data takes a lot of space, also …

read more

Uetke's website is on Github

At Uetke we seek to build simple, clear, modular and extensible codes that can be easily maintained and repurposed by developers other than their creators. Therefore we decided to make all the under-the-hood code freely available for others to read, learn, and improve. The code is hosted on Github in …

read more

New Courses of Git for Scientists

We are launching the course Git for Scientists aimed at researchers from different backgrounds and career stages. In the course, you will learn how to work with git, one of the best version control system of all times, and its different web implementations such as BitBucket, GitHub, and GitLab.

Git …

read more

The Importance of Doing a Backup

The ransomware attacks that occurred some months ago triggered a wave of people concerned about backups, finally! Ransomware attacks encrypted entire hard drives and the only way of recovering the data was by paying money to the hackers. This kind of attack is simply bypassed by a good back up …

read more

Agile Development for Science

Managing research projects and teams can benefit from the methodologies and processes developed in other fields of management. In recent decades, software development became a major industry that needed to establish its own set of rules and procedures. People working in the software industry and young scientists such as Ph …

read more

Get all the information directly to your inbox

Get relevant information, unsubscribe at any time.

© Copyright 2018 Uetke | Contact Us | RSS feed | Privacy Policy | Cookies