sshmercurialtortoisehghgrc

mercurial hg clone a repo from a server connected through another server


I have three machines

local (windows)
serverA (linux) with username as userA
serverB (linux) with username as userB

I want to clone a hg repository in serverB to my local machine using TortoiseHg for windows. The machine serverB can be sshed only though serverA. So in winScp/PuTTY I use tunneling option to connect to serverB through serverA. But how do I do it in TortoiseHg?

Obviously I cannot use hg clone ssh://userB@serverB://<path to repo>. But is there a way to use multiple ssh commands`. I tried the below approach and it did not work:

$cat ~/.ssh/config

host serverB.example.com serverB
    ProxyCommand /usr/bin/ssh serverA.example.com /usr/bin/nc %h %p

Solution

  • You have the following options:

    1. You can forward the ssh port on serverA, in your .ssh/config add something like:

      host serverBtunnel
         LocalForward    2222 serverB.example.com:22
      

      Then start the tunnel (on serverA) with:

      ssh -N serverBtunnel
      

      After this you can clone the repo (from your windows box) using:

      hg clone ssh://userB@serverA:2222//<path to repo>
      
    2. Create the tunnel directly from Putty (see here for more details). Basically:

      • You will define and add the tunnel to serverB: defineTunnel
      • Then create the session to serverA (that will have the tunnel defined): enter image description here
      • This way, on your windows box (assuming that the above session is started), you will be able to clone the repo, using:

        hg clone ssh://userB@localhost:2222//<path to repo>