ssh - 从通过另一台服务器连接的服务器克隆存储库

标签 ssh mercurial tortoisehg hgrc

我有三台机器

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

我想使用Windows的TortoiseHg将serverB中的hg存储库克隆到本地计算机。机器serverB仅可通过ssh进行serverA ed编辑。因此,在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

最佳答案

您有以下选择:

  • 您可以转发ssh上的serverA端口,在.ssh/config中添加以下内容:
    host serverBtunnel
       LocalForward    2222 serverB.example.com:22
    

    然后使用以下命令启动隧道(在serverA上):
    ssh -N serverBtunnel
    

    之后,您可以使用以下命令克隆存储库(从Windows框中):
    hg clone ssh://userB@serverA:2222//<path to repo>
    
  • 直接从Putty创建隧道(有关更多详细信息,请参见here)。基本上:
  • 您将定义隧道并将其添加到serverB:
    defineTunnel
  • 然后创建到serverA的 session (将定义隧道):
    enter image description here
  • 这样,在Windows框上(假设上述 session 已启动),您将能够使用以下命令克隆存储库:
    hg clone ssh://userB@localhost:2222//<path to repo>
    
  • 关于ssh - 从通过另一台服务器连接的服务器克隆存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34568988/

    相关文章:

    tortoisehg - 龟甲HG中缺少 list 按钮

    bash - rsync 在哪里保存完整和不完整数据传输的日志文件?

    Mercurial 信任问题

    windows - 在 Unicode 文件上的 Mercurial 中获得可读的差异显示 (MS Windows)

    php - 使用 Mercurial 进行开发和生产 php/MySQL 查询管理

    svn - 如何使用 TortoiseHg (Mercurial) 下载代码

    macos - 无法打开显示错误

    ssh - 使用 SSH 在 Azure Pipeline 中 checkout git 子模块

    bash - 通过ssh自动使用与用户默认设置不同的shell。

    git - git 中的 hg addremove