如何通过SSH协议诊断hg推送失败

时间:2017-06-30 12:01:54

标签: ssh mercurial

我正在尝试将变更集推送到远程存储库,但命令似乎没有任何反应。

我在Windows 8.1上运行最新版本的Mercurial(4.2)。无论是使用密钥身份验证还是基于密码验证,我都可以使用PuTTY和OpenSSH客户端SSH连接到我的服务器。

我的hgrc文件有:

[ui]
...
ssh = ssh -i "path_to_id_file" -2 -C

[defaults]
...
push = --debug

以下是我在命令行上输出的内容:

pushing to ssh://myuser@mydomain.com//var/hgrepos/projectx
running ssh -i "path_to_id_file" -2 -C myuser@mydomain.com "hg -R /var/hgrepos/projectx serve --stdio"
sending hello command
sending between command

之后,没有任何事情发生,几分钟。我希望必须将密码提供给我的私钥,就像我只需输入ssh myuser@mydomain.com时那样。 Ctrl + C不执行任何操作:我必须关闭窗口。

无论我是使用密钥还是密码验证,在“发送命令”之后,推送总是无限期地挂起。在某些时候,我认为我的密钥密码或密码是预期的,但键入要么没有产生任何积极的结果。

我使用HTTPS管理这个远程服务器和存储库多年,Mercurial通过该协议按预期工作。我正在逐步转向基于密钥的身份验证,而hg是这条路的最后一步。

上次信息:hg clone表现出相同的行为。

非常感谢一些帮助诊断这一点。

修改

我在服务器上启用了SSH日志,并在尾部/var/log/secure时得到了这些内容(这些行是我之前给出的4行的服务器端匹配):

Jul  4 13:15:40 vpsxxxxx sshd[11654]: debug1: Forked child 15779.
Jul  4 13:15:40 vpsxxxxx sshd[15779]: Set /proc/self/oom_score_adj to 0
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: inetd sockets after dupping: 3, 3
Jul  4 13:15:40 vpsxxxxx sshd[15779]: Connection from 176.188.xx.xx port 64160
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: Client protocol version 2.0; client software version OpenSSH_7.5
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: match: OpenSSH_7.5 pat OpenSSH*
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: Enabling compatibility mode for protocol 2.0
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: Local version string SSH-2.0-OpenSSH_5.3
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: permanently_set_uid: 74/74
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: list_hostkey_types: ssh-rsa,ssh-dss
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_KEXINIT sent
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_KEXINIT received
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: kex: client->server aes128-ctr umac-64@openssh.com zlib@openssh.com
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: kex: server->client aes128-ctr umac-64@openssh.com zlib@openssh.com
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_NEWKEYS sent
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: expecting SSH2_MSG_NEWKEYS
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: SSH2_MSG_NEWKEYS received
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: KEX done
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: userauth-request for user userx service ssh-connection method none
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: attempt 0 failures 0
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: PAM: initializing for "userx"
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: PAM: setting PAM_RHOST to "176.188.xx.xx"
Jul  4 13:15:40 vpsxxxxx sshd[15779]: debug1: PAM: setting PAM_TTY to "ssh"
Jul  4 13:15:40 vpsxxxxx sshd[15780]: debug1: userauth_send_banner: sent

除非我以错误的方式解释这一点,否则服务器似乎处于用户身份验证步骤,而客户端Mercurial已经在尚未打开的通信线路上发送命令,因为用户尚未经过身份验证。

1 个答案:

答案 0 :(得分:0)

我在使用SSH时终于成功了(再次,我多年前做过)。

问题似乎是使用OpenSSH软件包中的ssh.exe,或者(在我今天阅读的下面的网页上记录了这些,这帮助我摆脱了这个泥潭)服务器的密钥还没有缓存。然而,我已经手动连接到服务器,如问题所述,此外还有许多以前通过Putty,MobaXterm和ssh.exe的连接。

所需要的只是(见https://www.mercurial-scm.org/wiki/WindowsInstall)是Putty包和一些配置。

参考文献:

第二个特别简洁,对我帮助最大。

此时,我的.hgrc文件的相关内容如下:

[ui]
...
ssh = D:\Programs\putty\plink.exe -ssh -agent -2 -C -i "path-to-ppk-file"

我正在转换为SSH而不是HTTPS的本地存储库的hgrc文件包含:

[paths]
default-push=ssh://username@domain.tld:1234//var/hgrepos/projectx

请注意,Mercurial会分解该URI并将相应的参数显示在ui.ssh中指示的命令中。例如,hg clone ssh://username@domain.tld:1234//var/hgrepos/projectx在命令行窗口中产生此输出:

G:\Data\Temp>hg clone ssh://username@domain.tld:1234//var/hgrepos/projectx
running D:\Programs\putty\plink.exe -ssh -agent -2 -C -i "path-to-ppk-file" username@domain.tld -P 1234 "hg -R /var/hgrepos/projectx serve --stdio"
sending hello command
sending between command
remote: 329
remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream bundle2=HG20%0Achangegroup%3D01%2C02%0Adige
sts%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2
Chttps unbundle=HG10GZ,HG10BZ,HG10UN
remote: 1
destination directory: projectx
query 1; heads
sending batch command
requesting all changes
sending getbundle command
bundle2-input-bundle: with-transaction
bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
adding changesets
add changeset 279e0cde0d10
....