【问题标题】:mercurial hg clone a repo from a server connected through another servermercurial hg 从通过另一台服务器连接的服务器克隆 repo
【发布时间】:2016-01-02 18:02:31
【问题描述】:

我有三台机器

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

我想使用 TortoiseHg for windows 将serverB 中的 hg 存储库克隆到我的本地计算机。机器serverB 只能是sshed,尽管serverA。所以在 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

【问题讨论】:

  • 您所说的“没有工作”是什么意思?您是否也尝试过代理命令的-w 方式?

标签: ssh mercurial tortoisehg hgrc


【解决方案1】:

您有以下选择:

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

    host serverBtunnel
       LocalForward    2222 serverB.example.com:22
    

    然后启动隧道(serverA):

    ssh -N serverBtunnel
    

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

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

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

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

【讨论】:

  • 我的本地机器窗口。
  • ~/.ssh/config 的所有者或权限不正确。我需要在这个文件上设置权限吗
  • .ssh 目录的权限应该是700,对于config,你应该使用640
  • 我认为我添加的腻子替代方案更简单,您不再需要登录serverA。但是在第一个选项中,要在serverA 上启动该隧道,您将使用ssh -N userA@serverBtunnel
  • UserA@serverBtunnel?不应该是userB@serverBtunnel吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-27
  • 2014-05-20
  • 2023-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多