在 ssh 上进行 Git 推送在窗口上失败并出现'the remote end hung up unexpectedly'错误



我希望有人能帮助我,因为我已经为此奋斗了好几天,但被难住了。我已经在一台运行Windows10的全新笔记本电脑上设置了标准的git客户端(来自gitscm.com(,并且正在Github.com上托管一个存储库

最初,我在SSH配置中遇到了一些冲突,因为本机Windows OpenSSH客户端与git附带的捆绑SSH客户端发生了冲突。所以身份验证失败了。根据Adam Ralph的建议,我已经通过显式设置全局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

我一直在搜索谷歌和stackoverflow,并尝试了我能找到的所有解决方案:

  • http.postbuffer值设置为500MB-1GB(尽管我的repo没有大文件,只有少数小的typescript文件(
  • 完全卸载内置的Windows OpenSSH客户端
  • 已安装各种版本的Git客户端2.17.1、2.19.2、2.20.1(当前最新版本(
  • 在其他几台运行Windows 10 Pro的计算机上,使用相同的存储库,对相同添加/更改的文件的子集尝试相同的git push命令,进行了一些健全性检查
  • 重新安装git客户端,禁用LFS支持,然后在repo上运行git filter-branch以清理repo
  • 尝试将repo多次重新克隆到新文件夹
  • 尝试更改为使用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

我已经按照Adam Ralph的建议通过显式设置全局sshCommand配置值来解决了这个问题。

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

set PATH=C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0
set GH=C:pathtogit
set PATH=%GH%bin;%GH%usrbin;%GH%mingw64bin;%PATH%
git config --gobal --unset core.sshCommand
cd C:pathtorepo
git config --local --unset core.sshCommand

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

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

对windows运行gitbash(不要使用openssh,只使用gitbash(,然后输入以下命令

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,再次在这里发布错误日志,我会帮助你完成它。

我很抱歉,但我必须通知您,"致命:远程端意外挂断"这条消息主要来自远程端。

  • 您的数据资产会导致远程崩溃(甚至github也可能发生这种情况(
  • SSH超时,请参阅:ServerAliveInterval
  • 您的连接不符合TLS协议,即:MTU大小无效(一些ISP使用GRE隧道(请尝试更低的MTU:1436
  • 您可以使用wireshark来追踪是什么触发了TCP中止,因为您正在通过TCP协议进行通信,而且wireshark还可以解码一些SSH数据包

相关内容

最新更新