关于Mercurial:如何在不使用PuTTY的情况下从命令行使用TortoiseHg(选美)

How to use TortoiseHg from command line without PuTTY (Pageant)

之前我使用Mercurial命令行安装,并且对于默认的ssh客户端和?/ .ssh中的键位置,它对我来说运行良好。

在我的新笔记本电脑上,我安装了TortoiseHg。 现在,任何远程请求(例如汞拉或汞传入)都会生成PuTTY致命错误:

Disconnected: No supported authentication methods available (server sent: publickey)

enter image description here

如果我尝试直接通过ssh访问存储库,则会得到类似的结果:
ssh -vT [email protected]

可以使用Pageant(plink)解决该问题:运行它并添加油灰键,或将选美(plink)添加到Mercurial配置文件中。

但是,我正在寻找如何仅使用默认的ssh密钥位置以旧的方式工作,而没有页面或链接的问题?


看起来与git相反,Mercurial不提供自己的ssh客户端,因此必须使用Plink和Pageant,但有两种解决方法:

  • 使用TortoisePlink作为ssh客户端,并在Mercurial配置(%USERPROFILE%\。hgrc或%USERPROFILE%\ Mercurial.ini)中使用显式键引用:

    [ui]

    ssh ="C:\\Program Files\\TortoiseHg\\lib\\TortoisePlink.exe" -ssh -i %USERPROFILE%.ssh\\id_rsa.ppk

  • 如果已安装gitcygwin(或在Windows上使用ssh的任何其他方式),则可以在Mercurial配置中使用第三方ssh客户端指向路径:

    [ui]

    ssh ="C:\\Program Files (x86)\\Git\\bin\\ssh.exe"

    # or

    # ssh ="PATH_TO_ANY_OTHER_SSH_CLIENT_LIKE_CYGWIN"

  • 我尝试了两种方式-它们效果很好。

    我使用第二个,因为我在PC上使用git分布式工具作为主要的ssh代理。如果您的PC上没有ssh替代项,则第一个选项是合适的。

    笔记:

    • 有时,基于解析器,ini文件中的路径用字符转义了,因此\可能会转义下一个符号。在这种情况下,路径应类似于C:\\ Program Files(x86)\\ Git \\ bin \\ ssh.exe(带有双斜杠)
    • 我在%PATH%变量中有git \ bin目录,以使用ssh而不指定完整路径。在这种情况下,您可以在Mercurial配置中使用以下命令:

      [ui]

      ssh = ssh


    不,除了TortoiseHg本身以外,没有安装或使用某些软件就没有任何办法。

    Mercurial本身不实现SSH。在Unix上,它仅运行ssh并期望已经安装了合适的客户端(这是一个安全的选择,因为绝大多数Unix系统要么预先安装了SSH客户端,要么可以相对容易地安装一个SSH客户端)。在Windows上,这不是一个合理的假设,因此TortoiseHg捆绑了一个客户端:

    SSH is a symmetrical peer-to-peer secure tunnel. SSH clients and servers have their own key management systems, so Mercurial does not get involved with password prompts when SSH is used. This is problematic on Windows and thus TortoiseHg bundles the TortoisePlink SSH client with its Windows installers. TortoisePlink is a port of the Plink SSH client that uses dialog prompts for host-key authorizations and passphrase prompts. TortoisePlink (developed by the TortoiseSVN project) can use the other SSH tools that are part of the Plink toolchain, including the Pageant key agent.

    如果您不使用TortoisePlink,则很可能没有TortoiseHg可以与其连接的SSH客户端。而且,如果您不使用Pageant,那么将没有保存密钥的系统。 TortoisePlink不使用~/.ssh,因为Windows并非这样做。


    使用TortoiseHg时,如何防止出现"没有可用的支持的身份验证方法"错误?

    获取/运行puttygen.exe,在关闭窗口之前,单击"生成"(无密码),然后单击"保存pubkey","保存PrivKey"。复制所有关键文本,(或者您必须返回到puttygen)并将其粘贴到BitBucket网页上的Account / Profile / Settings / Security / SSHKeys区域。
    (右键单击)systray中的pageant.exe图标-单击"添加密钥"。
    退出选美并重新加载它以确保。退出乌龟并重新加载它以确保。好去。