1

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
Guildencrantz
  • 1,875
  • 1
  • 16
  • 30
arunmoezhi
  • 3,082
  • 6
  • 35
  • 54

1 Answers1

2

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>
      
dan
  • 13,132
  • 3
  • 38
  • 49
  • my local machine windows. – arunmoezhi Jan 02 '16 at 18:47
  • Bad owner or permissions on `~/.ssh/config`. Do I need to set permissions on this file – arunmoezhi Jan 02 '16 at 18:54
  • The permissions on `.ssh` directory should be `700` and for `config` you should use `640`. – dan Jan 02 '16 at 18:56
  • I think that the putty alternative, that I added, is simpler and you don't need to log to `serverA` anymore. But on the first option, to start that tunnel on `serverA`, you will use `ssh -N userA@serverBtunnel ` – dan Jan 02 '16 at 19:15
  • UserA@serverBtunnel? Shouldn't it be userB@serverBtunnel? – arunmoezhi Jan 02 '16 at 19:57
  • No, when using `serverBtunnel` you need to use the `userA`, because on `serverA` we are creating the tunnel. – dan Jan 02 '16 at 20:40
  • I have no idea why the first option is not working for me. But the configuration via PuTTY works just fine. Thanks – arunmoezhi Jan 03 '16 at 06:52