【问题标题】:Git push over ssh fails on windows with 'the remote end hung up unexpectedly' errorGit push over ssh 在 Windows 上失败,出现“远程端意外挂断”错误
【发布时间】:2020-03-19 08:30:28
【问题描述】:

我希望有人可以帮助我,因为我已经为此苦苦挣扎了好几天,并且很困惑。我已经在运行 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 专业版且具有相同存储库的其他几台计算机上尝试使用相同的添加/更改文件的子集执行相同的 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

【问题讨论】:

    标签: git github ssh


    【解决方案1】:

    根据 Adam Ralph 的建议,我设法通过显式设置全局 sshCommand 配置值来解决这个问题。

    是,但不是:首先尝试在 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 问题是否仍然存在。

    【讨论】:

      【解决方案2】:

      写入几个字节后连接关闭, 目标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,再把错误日志贴在这里,我帮你解决。

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          猜你喜欢
          • 2021-08-02
          • 2011-10-04
          • 2012-08-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-04-23
          • 2021-08-04
          相关资源
          最近更新 更多