Forum Discussion
Chosing which SSH key to use
Hi @purrpledev, XIII is right that you can leverage the SSH configuration to achieve this. Here's four steps to take to achieve this:
- Download the public key for both SSH key items:
Move the public keys to your
~/.ssh/directory.Configure hosts for your personal and work GitHub profile by appending the following to your
~/.ssh/config:
```
Personal GitHub
Host personalgit
HostName github.com
User git
IdentityFile ~/.ssh/personal_git.pub
IdentitiesOnly yes
Work GitHub
Host workgit
HostName github.com
User git
IdentityFile ~/.ssh/work_git.pub
IdentitiesOnly yes
```
Make sure the IdentityFile matches the names of the files at step 2.
- For each repo, change the git URL to use one of the new hosts instead of
git@github.com:
git remote set-url origin <host>:<workplace>/<repo>.git
For example:
git remote set-url origin personalgit:1password/1password-teams-open-source.git
Now your SSH clients will know which SSH key to use for each repository and the right GitHub account will be used for each.
I'll also file a feature request on your behalf to explore if we can detect the duplicate configuration and prompt for you to pick an SSH key if so.