TortoiseHg (Mercurial) normally uses TortoisePLink/plink to connect via SSH. Different SSH hosts have different settings, including private keys and ports to connect to.
In its global hgrc settings, TortoiseHg lets you specify different logins and passwords for different hosts, but not private keys nor ports.
How to override SSH port/private key globally, but only for some hosts and not others?
I'll list a number of imperfect approaches for completeness, then give the one I've found that I think is better:
ssh setting
Mercurial
sshsetting can be used to pass additional params to plink globally:But the same
sshstring is used for all hosts, so different ports cannot be configured. And while you can list several private keys, some servers will refuse all but the first one.putty's saved sessions
plink comes from putty package, and putty can store server configurations (sessions) in the registry,
HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions. plink can use these if you use a session name in the host place, e.g.ssh://session-name/path/to/repository.But for some reason plink ignores stored port settings and will use the default SSH port. Probably a bug, but it's unfixed.
Local hgrcs
You can override
sshfor each repository by creating a local.hgrcfile, but it's unwieldy if you have lots of repos.Explicit ports
You can specify ports explicitly in the remote repository address:
Same problems as with local hgrcs.
PLink script wrapper
After struggling with this for a while, I have finally thought of something that seems to work. We can wrap TortoisePLink in a script that adds per-server params:
Create a file called
[email protected]for every host you want to override, and its contents should be additional params to pass to TortoisePLink, e.g.:Place this in the same dir: