Handling multiple SSH keys
Created at 2019-11-03 Updated at 2023-03-08 - 2 min. read
Life was going awesome until the problem came of using a key for different repository while using another set of keys for another set of a repository. Which brings me to the problem of handling multiple SSH keys. So let’s start the process of understanding how to manage them.
Firstly you need to understand that to manage the ssh keys you need to have a config file. That can be found at the
~/.ssh folder with the name
config. It’s not present initially, In that case, one needs to create it by the following command.
After this, you need to set the permission for the file.
chmod 700 ~/.ssh/config
The format of the config file is given bellow
Since we would be using the config for the repository cloning and accessing of the Github. Let’s suppose we have two sets of keys. Each set includes a private and public key. Filename of the each set is id_rsa1 & id_rsa2. Hence the updated config file looks like this.
Now if you want to clone the repository using the id_rsa2 key. You need to make some changes while writing the git URL. For example, let’s suppose the original URL you need to clone is
This would be using the id_rsa1 key to clone the repository.
If you want to clone with id_rsa2 key. You need to change the domain of the repository URL.
So the new URL would be
github.com has been replaced with
Happy SSHing :)