在Windows上的Git push over ssh失败,出现“远程端意外挂起”错误

时间:2018-12-15 21:30:40

标签: git github ssh

我希望有人可以帮助我,因为我已经为此奋斗了好几天,并为此感到沮丧。我已经在运行Windows 10的全新笔记本电脑上设置了标准git客户端(来自git-scm.com),并正在Github.com上托管的存储库中。

最初,由于本地Windows OpenSSH客户端与git附带的捆绑的SSH客户端发生冲突,我在SSH配置中遇到了一些冲突。因此身份验证失败。通过设法根据Adam Ralph's suggestion显式设置全局sshCommand配置值,可以解决此问题。这使我摆脱了身份验证问题,并且能够很好地从GitHub进行克隆,获取和提取。但是,当我尝试推送时,我没有遇到以下错误。

Counting objects: 15, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (15/15), 3.20 KiB | 252.00 KiB/s, done.
Total 15 (delta 1), reused 0 (delta 0)
Connection to github.com closed by remote host.
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

我一直在搜索google和stackoverflow,并尝试了所有可以找到的解决方案:

  • http.postbuffer的值设置为500MB-1GB(尽管我的仓库没有大文件,只有少量的小型打字稿文件)
  • 完全卸载了内置的Windows OpenSSH客户端
  • 安装了各种版本的Git客户端2.17.1、2.19.2、2.20.1(当前最新版本)
  • 通过在具有相同存储库的其他几台运行Windows 10 Pro的其他计算机上尝试对相同的已添加/更改文件的子集执行相同的git push命令,进行了一些健全性检查
  • 重新安装git客户端,禁用LFS支持,然后在仓库上运行git filter-branch以清理仓库
  • 尝试将存储库的多个重新克隆到一个新文件夹
  • 尝试转换为使用HTTPS而不是SSH。这似乎是取消推送到我的GitHub存储库的唯一方法
  • 通过将sshCommand设置为ssh -vv来打开更详细的日志记录。这样会将控制台日志记录更新为在下面阻止。

在这一点上,我可以通过切换到HTTPS远程连接来取消能够实际执行的工作,但是在使用git的几年中,我从未遇到过使用SSH这样的问题。有没有人遇到过这样的事情?有什么明显的我想念的吗?

OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "github.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to github.com [192.30.253.112] port 22.
debug1: Connection established.
debug1: identity file /c/Users/John/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/John/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.7
debug1: Remote protocol version 2.0, remote software version babeld-f43b814b
debug1: no match: babeld-f43b814b
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256
debug2: host key algorithms: ssh-dss,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib,zlib@openssh.com
debug2: compression stoc: none,zlib,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/John/.ssh/known_hosts:1
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug2: key: /c/Users/John/.ssh/id_rsa (0x600061250)
debug2: key: /c/Users/John/.ssh/id_dsa (0x0)
debug2: key: /c/Users/John/.ssh/id_ecdsa (0x0)
debug2: key: /c/Users/John/.ssh/id_ed25519 (0x0)
debug2: key: /c/Users/John/.ssh/id_xmss (0x0)
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:0imySt9BYYbsr5CLqXP5JRHwHNCXAYuotf8/6WGE4sU /c/Users/John/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp SHA256:0imySt9BYYbsr5CLqXP5JRHwHNCXAYuotf8/6WGE4sU
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.253.112]:22).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Entering interactive session.
debug1: pledge: network
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug1: Sending command: git-receive-pack 'john-shaskin/polly-notes-reader.git'
debug2: channel 0: request exec confirm 1
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 32000 rmax 35000
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Counting objects: 15, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (11/11), done.
Writing objects:  13% (2/15)   1248163Writing objects:   6% (1/15)
Writing objects: 100% (15/15), 3.20debug2: channel 0: read<=0 rfd 4 len 0 KiB | 192.00 KiB/s, done.
Total 15 (delta 1), reused 0 (delta 0)
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain -> closed
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
pectedlychannel 0: output drain -> closedfatal: The remote end hung up unexpectedly
fatal: The remote end hung up unex
debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed by remote host.
Transferred: sent 6880, received 2096 bytes, in 0.5 seconds
Bytes per second: sent 13415.2, received 4087.0
debug1: Exit status -1

3 个答案:

答案 0 :(得分:2)

我已经设法通过按照Adam Ralph的建议显式设置全局sshCommand config值来解决。

是,但不是:首先尝试在CMD会话中使用Git,在该会话中您放置了简化的PATH,在该会话中,Git捆绑的openSSH将首先出现并被使用(OpenSSH_8.2p1,OpenSSL 1.1.1d 9月10日2019),而不是Windows中的旧版本

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

git config --gobal --unset core.sshCommand
cd C:\path\to\repo
git config --local --unset core.sshCommand

然后在该CMD会话中再试一次,以测试SSH问题是否仍然存在。

答案 1 :(得分:1)

写入几个字节后,连接将关闭, 目标https://github.com/john-shaskin/polly-notes-reader 请尝试以下操作:

在Windows上运行git bash(请勿使用openssh,仅使用git bash),然后输入以下命令

git config --global http.postBuffer 524288000
git config --global ssh.postBuffer 524288000

使用简单的设置进行git push

git config --global push.default simple

将文件夹更改为要提交的存储库

cd /{driveletter}/{rootdir}/{repo}/{src}

cd /d/projects/repo/src <---- change accordingly.

现在尝试

git push 

如果仍然出现错误,则需要启用GIT_TRACE_PACKET = true和GIT_TRACE = 2,再次将错误日志发布到此处,我将为您提供帮助。

答案 2 :(得分:0)

非常抱歉,但我必须通知您,“致命:远端意外挂断”,此消息主要来自远端。

  • 您的数据资产会导致远程崩溃(即使使用github也可能发生)
  • SSH超时,请参阅:ServerAliveInterval
  • 您的连接不适用于TLS协议,即:MTU大小无效(某些ISP使用GRE隧道)尝试降低MTU:1436
  • 您可以使用wireshark跟踪由于通过TCP协议进行通信而触发TCP中止的原因,并且wireshark也可以解码一些SSH数据包。