This will be a question and an answer together.
My goal is to have GitHub(via git) and BitBucket(via hg) co-exist on the same machine, both using SSH keys for all repos of each respective type.
Setup: Windows 10 git-scm tortoisehg
(Despite using Win 10, I'll be describing bash paths. Anywhere you see a "~", just replace that with "C:\users\yourName")
There are lots of other questions and answers on this, but none of them really pointed me in the direction I needed.
For me, GitHub is my "primary" and BitBucket is my "secondary" This guide gets me the first ssh key, which I save as "id_rsa" in the "~/ssh" folder. https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
BitBucket is my secondary, and so I create a second key, with the custom name "bb_rsa" https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
And the answer will be the final step that makes it all work.
TortoiseHG uses ~/mercurial.ini
for the HG settings, but other mercurial installations might use ~/hgrc
or ~/.hgrc
. Make sure you know which one is right for you.
In your mercurial.ini
or hgrc
file, add the following:
[paths]
ssh = ssh -C -i ~/.ssh/bb_rsa
[ui]
ssh = ssh -C -i ~/.ssh/bb_rsa
One or both will do the trick for you.
After that, all of your git commands will use the ~/.ssh/id_rsa
key, and all your hg commands will use the ~/.ssh/bb_rsa
key.