Mercurial over ssh with config file
Say I have the following ssh .config file:
Host host_nickname
User xxx
HostName yyy.zz.vvv
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
In case you are not familiar with ControlMaster or ControlPath, here is the description from the ssh_config manual:
ControlMaster:
Enables the sharing of multiple sessions over a single network
connection. When set to ``yes'', ssh(1) will listen for connec-
tions on a control socket specified using the ControlPath argu-
ment. Additional sessions can connect to this socket using the
same ControlPath with ControlMaster set to ``no'' (the default).
These sessions will try to reuse the master instance's network
connection rather than initiating new ones, but will fall back to
connecting normally if the control socket does not exist, or i开发者_运维百科s
not listening.
In Mercurial, if you want to push or pull from a repository, you could just type the following:
hg push ssh://user@example.com/hg/
Now, my question:
I would like to ask Mercurial to push (or pull) against a repository at /path/to/repository
on the server corresponding to my ssh config entry host_nickname. How do I do this?
If you look under hg help urls
you'll find
ssh://[user@]host[:port]/[path][#revision]
So, assuming that /path/to/repository
works from your login dir on the remote machine, then type
hg [push|pull] ssh://host_nickname/path/to/repository
This works because hg
isn't doing the name resolution; ssh
is, and you've specified the correspondence between host_nickname
and the real HostName
. Also, ControlMaster
won't affect this, as that just allows multiplexing over a single ssh connection. Note, if hg
isn't in your remote PATH
, then you need to specify it via --remotecmd /path/to/hg
.
精彩评论