简体   繁体   English

Git克隆产生错误的数据包长度错误

[英]Git clone produces bad packet length error

I have trouble pulling a git repository via ssh on Windows. 我在Windows上通过ssh提取git存储库时遇到问题。 The repository is on a GitLab Server. 存储库位于GitLab服务器上。 I do the following steps: 我执行以下步骤:

  1. create a public key with ssh-keygen -t rsa -C "my@email.here" 使用ssh-keygen -t rsa -C "my@email.here"创建公钥
  2. save the keys in C:\\Users\\myUserName\\.ssh\\keyName 将密钥保存在C:\\Users\\myUserName\\.ssh\\keyName
  3. run the output of ssh-agent (ie export SSH_AUTH_SOCK; ...) 运行ssh-agent的输出(即导出SSH_AUTH_SOCK; ...)
  4. run ssh-add and add the key in C:\\Users\\myUserName\\.ssh\\keyName 运行ssh-add并在C:\\Users\\myUserName\\.ssh\\keyName添加密钥
  5. add the public key in GitLab. 在GitLab中添加公钥。

The same setup works fine on my Linux and on the Windows machines of my colleagues. 相同的设置在我的Linux和我的同事的Windows机器上运行良好。 When i try to clone a repository with git clone I get the following error: 当我尝试使用git clone克隆存储库时,我收到以下错误:

Disconnecting: Bad packet length 1397966893. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

I tried to google it, but i found nothing appropriate. 我试着谷歌,但我发现没有什么合适的。 Does somebody know if i may have made a mistake or that the bug may be server-side? 有人知道我是否犯了错误或者错误可能是服务器端的吗?

EDIT:I get the following debug output: 编辑:我得到以下调试输出:

C:\Users\Johannes\Documents\GitHub> ssh -vT -p 80 git@random.secret.sever.de
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/Johannes/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to random.secret.sever.de [192.44.1.37] port 80.
debug1: Connection established.
debug1: identity file /c/Users/Johannes/.ssh/identity type -1
debug1: identity file /c/Users/Johannes/.ssh/id_rsa type 1
debug1: identity file /c/Users/Johannes/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
Disconnecting: Bad packet length 1397966893.

EDIT 2: Looks like my problem is based in my hard- and software setup. 编辑2:看起来我的问题是基于我的硬件和软件设置。 Just did the same steps in parallel and it worked on the other computer. 刚刚并行完成了相同的步骤,它在另一台计算机上运行。

Found the cause for my problem by accident. 偶然找到了我的问题的原因。 I tried to use an old trick and started a System Recovery to undo my Git installation. 我尝试使用旧技巧并启动系统恢复以撤消我的Git安装。 It failed because of my Virus Scanner. 由于我的病毒扫描程序,它失败了。 After uninstalling Bitdefender Antivirus Free Edition it worked. 卸载Bitdefender Antivirus免费版后,它工作正常。 Incoming SSH2 messages were blocked (got Windows 8 Pro) which caused the bad packet length error. 传入的SSH2消息被阻止(获得Windows 8 Pro),导致bad packet length错误。 Anyway, thanks for your support! 无论如何,感谢您的支持!

save the keys in C:\\Users\\myUserName\\.ssh\\keyName 将密钥保存在C:\\Users\\myUserName\\.ssh\\keyName

Your local ssh command would look for ssh keys in %HOME%\\.ssh\\id_rsa(.pub) . 您的本地ssh命令将在%HOME%\\.ssh\\id_rsa(.pub)查找ssh密钥。

So you need to either: 所以你需要:

  • rename the local files representing your ssh (public and private) keys 重命名代表ssh(公钥和私钥)的本地文件
  • or reference those through a %HOME%\\.ssh\\config which can reference the exact name of your private key (with an IdentityFile directive ). 或者通过%HOME%\\.ssh\\config引用它们,它们可以引用私钥的确切名称(使用IdentityFile指令 )。

     Host gitlab user git hostname your.gitlab.server.com IdentityFile C:\\user\\YourUsername\\.ssh\\keyName 

In the second case, the ssh url would be gitlab:yourRepo . 在第二种情况下,ssh url将是gitlab:yourRepo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM