If you wish to configure multiple SSH keys on your computer because you use it for both work and personal projects, you need to set up different users in your repository.
Assuming that the first key is referred to as a “personal_key” and the second is referred to as a “work_key," both of which have their own public files extensions, you can edit the config file (~/.ssh/config) to include the following details.
Host work-github.com
HostName github.com
User git
IdentityFile ~/.ssh/work_key
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/personal_key
Once saved, go to the working folder where you are running this project from (for example home/dashpy/work) and use command git remote -v. This should bring up something similar to:
$ git remote -v
origin git@github.com:dashpy/insight.git (fetch)
origin git@github.com:dashpy/insight.git (push)
We want to change that and tell git that when I'm working in this work project use my work ssh key, so to do that we type
git remote set-url origin git@work-github.com:Company/product.git
Which will tell Git that it should use your work SSH key when this particular working project is used.
The end.
Top comments (0)