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

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

我有三台机器

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

我想使用 windows 的 TortoiseHg 将 serverB 中的 hg 存储库克隆到我的本地计算机。机器 serverB 只能通过 serverA 编辑 ssh。所以在 winScp/PuTTY 中,我使用隧道选项通过 serverA 连接到 serverB。但是我如何在 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. 您可以转发 serverA 上的 ssh 端口,在您的 .ssh/config 中添加如下内容:

    host serverBtunnel
       LocalForward    2222 serverB.example.com:22
    

    然后启动隧道(在 serverA 上):

    ssh -N serverBtunnel
    

    在此之后,您可以使用以下方法克隆存储库(从您的 windows 框中):

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

    • 您将定义隧道并将其添加到 serverB
    • 然后创建到 serverA 的会话(这将定义隧道):
    • 这样,在您的 windows 框中(假设上述会话已启动),您将能够使用以下方法克隆存储库:

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