mercurial hg克隆来自通过另一台服务器连接的服务器的repo

时间:2016-01-02 18:02:31

标签: ssh mercurial tortoisehg hgrc

我有三台机器

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

我想使用TortoiseHg for Windows将serverB中的hg存储库克隆到我的本地计算机。机器serverB只能ssh serverA。所以在winScp / PuTTY中我使用隧道选项通过serverB连接到serverA。但是我如何在TortoiseHg中做到这一点?

显然我不能使用hg clone ssh://userB@serverB://<path to repo>。但有没有办法使用多个ssh命令。我尝试了以下方法,它没有用:

$cat ~/.ssh/config

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

1 个答案:

答案 0 :(得分:2)

您有以下选择:

  1. 您可以转发ssh上的serverA端口,在.ssh/config中添加以下内容:

    host serverBtunnel
       LocalForward    2222 serverB.example.com:22
    

    然后使用:

    启动隧道(在serverA上)
    ssh -N serverBtunnel
    

    在此之后,你可以使用:

    克隆回购(从你的窗口框)
    hg clone ssh://userB@serverA:2222//<path to repo>
    
  2. 直接从Putty创建隧道(有关详细信息,请参阅here)。基本上是:

    • 您将定义隧道并将其添加到serverBdefineTunnel
    • 然后创建到serverA的会话(将定义隧道): enter image description here
    • 这样,在您的Windows框中(假设上面的会话已启动),您将能够使用以下方法克隆回购:

      hg clone ssh://userB@localhost:2222//<path to repo>
      
相关问题