I am using ssh publickey authentication for my mercurial repository. So I have:
[ui]
ssh = ssh -i ~/.ssh/id_rsa -C
in my .hgrc. This works fine and allows me to push/pull to an ssh-authenticated repo. However, I want to be able to push/pull to another repo that requires a different identity. How can I configure my .hgrc file so the identity is tied to a particular path. I guess I'd want something like:
[ui]
one.prefix = someserver.com
one.ssh = ssh -i ~/.ssh/id_rsa -C
two.prefix = otherserver.com
two.ssh = ssh -i ~/.ssh/otherid_rsa -C
You use SSH for connecting to remote servers, which also includes managing your code using Git and syncing with remote repositories. Even though it is considered a good practice to have one private-public key pair per device, sometimes you need to use multiple keys and/or you have unorthodox key names.
For instance, you can run an Organization's GitHub account and another one for your personal projects all on the same computer. In this article, you will learn how to use multiple SSH keys for different GitHub accounts. While working with two different GitHub accounts, you must set them up using an SSH key.
In your ~/.ssh/config
, add
Host someserver.com
IdentityFile ~/.ssh/id_rsa
Host otherserver.com
IdentityFile ~/.ssh/otherid_rsa
and anybody (including hg
and interactive use) using ssh
to connect to hosts someserver.com
or otherserver.com
will use the specified identity files.
See ssh_config
for other options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With