DEV Community

Ishan
Ishan

Posted on • Originally published at ishan.page on

Using different Github accounts with different private keys on Linux

Create a file ~/.ssh/config

If you have 2 keys, for example: id_rsa for your personal, and id_work for your work, set the config as:

Host github-work
    HostName github.com
    IdentityFile ~/.ssh/id_work
    IdentitiesOnly yes

Enter fullscreen mode Exit fullscreen mode

Now, when cloning or adding remote, change the github.com in the clone url is changed to github-work

git clone git@github-work:username/whatever.git

Enter fullscreen mode Exit fullscreen mode

Top comments (0)