【问题标题】:hg doesn't connect to bitbucket using a custom keyhg 未使用自定义密钥连接到 bitbucket
【发布时间】:2012-03-18 20:37:45
【问题描述】:

在我的电脑上

.ssh/config:

Host bitbucket
    HostName bitbucket.org
    User hg
    IdentityFile ~/.ssh/id_rsa_pwd  

.hg/hgrc

[paths]
default = ssh://hg@bitbucket.org/lohoris/varlibs

(运行 OSX 10.6)

我在 debian 服务器上有完全相同的文件,但在“尝试”shell 登录时,两者都可以:

PTY allocation request failed on channel 0
conq: logged in as lohoris.

                           You can use git or hg to connect to Bitbucket. Shell access is disabled.
                                                                                                   Connection to bitbucket.org closed.

mercurial 连接只能在我的电脑上工作,而从服务器它拒绝合作:

lohoris@office:~/www/varlibs$ hg pull
remote: Permission denied (publickey).
abort: no suitable response from remote hg!

这与您在密钥错误时收到的消息相同,只是它当然没有错误(正如我所说,尝试ssh bitbucket 确实有效)。

可能使用了错误的密钥,因为它甚至没有试图询问我的密码,但我无法理解为什么

【问题讨论】:

    标签: mercurial bitbucket ssh-keys


    【解决方案1】:

    如果你得到“Permission denied (publickey)”,这只是意味着无法找到访问和推送到服务器所需的公钥。为了解决这个问题,您将运行以下命令:

    ssh-agent
    ssh-add <full path to your key file>
    

    ssh -T hg@bitbucket.org 也是一个又好又快的 ssh 调试器

    【讨论】:

    • 使用 ssh-agent 有效,但这并不是我想要做的。我现在注意到hg pull -e "ssh -i ~/.ssh/id_rsa_pwd" 也可以工作,所以我想问题在于当 hg 使用 ssh 时,它会忽略 .ssh/config 文件并使用默认密钥。我能做些什么呢?
    • [ui] ssh = ssh -C -i ~/.ssh/id_rsa_pwd 添加到.hg/hgrg 成功了。
    【解决方案2】:

    在你的路径中,你应该使用ssh://bitbucket/lohoris/varlibs,而不是ssh://hg@bitbucket.org/lohoris/varlibs

    【讨论】:

    • 根据文档,用户应该是 mercurial 的 hg 和 git 的 git。见confluence.atlassian.com/display/BITBUCKET/…
    • 是的,这就是他的~/.ssh/config 文件中的内容。
    • 我明白了。我断章取意地读了你的答案。也许值得在您的回答中重复他对“用户 hg”的特定配置会影响他的 ssh 命令。
    猜你喜欢
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 2015-08-13
    • 2023-04-06
    • 2017-03-13
    • 2022-01-21
    • 2022-12-14
    • 1970-01-01
    相关资源
    最近更新 更多