如何解决git fetch时遇到的bad packget length问题

浏览:41日期:2023-10-26

问题描述

下面的调试信息或者会有帮助。

$ git fetchBad packet length 1397966893.Disconnecting: Packet corruptfatal: The remote end hung up unexpectedly$ ssh -T git@coding.net -vvvOpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012debug1: Reading configuration data /home/honwhy/.ssh/configdebug1: /home/honwhy/.ssh/config line 1: Applying options for coding.netdebug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug2: ssh_connect: needpriv 0debug1: Connecting to coding.net [118.192.93.38] port 22.debug1: Connection established.debug3: Incorrect RSA1 identifierdebug3: Could not load '/home/honwhy/.ssh/coding_rsa' as a RSA1 public keydebug1: identity file /home/honwhy/.ssh/coding_rsa type 1debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048debug1: identity file /home/honwhy/.ssh/coding_rsa-cert type -1debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2debug1: match: OpenSSH_6.2 pat OpenSSH*debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.4debug2: fd 3 setting O_NONBLOCKdebug3: load_hostkeys: loading entries for host 'coding.net' from file '/home/honwhy/.ssh/known_hosts'debug3: load_hostkeys: loaded 0 keysdebug1: SSH2_MSG_KEXINIT sentBad packet length 1397966893.Disconnecting: Packet corrupt

问题解答

回答1:

经过我的搜索,问题解决了参考这两个链接https://blog.flameeyes.eu/2011/01/mostly-unknown-openssh-trickshttps://blogs.oracle.com/janp/entry/ssh_messages_code_bad_packet以下是修改后的~/.ssh/config配置

Host coding.netHostName coding.netUser myemail@mydomain.comIdentityFile /home/honwhy/.ssh/coding_rsaProtocol 2ControlMaster autoControlPersist yes

这两行配置比较重要

ControlMaster autoControlPersist yes

第一次链接时还是会提示错误,第二次链接就可以正常连接了。详细过程真的应该去读读手册、或者RFC,第二个链接中也说得很具体了。

THE END
相关文章: