WRITELOOP

MULTIPLE SSH KEYS ON GITHUB/BITBUCKET

2017 August 8

Multiple ssh keys on bitbucket/github:

That can be done on two steps: a) add the key to ~/.ssh/config b) change the local config of the project. For example:

# ~/.ssh/config
Host work
HostName bitbucket.org
IdentityFile ~/.ssh/work
Host personal
HostName bitbucket.org
IdentityFile ~/.ssh/personal

In the project local git config, change the host part of the remote URL to the appropriate host. E.g.:

# ~/repos/myworkproject/.git/config
# or you can access this file by going into the repo and running `git config -e`
...snip...
[remote "origin"]
fetch = ...
url = git@bitbucket.org:mybitbucketusername/myworkproject.git

Change the url line to:

url = git@work:mybitbucketusername/myworkproject.git