SSH Git 连接错误:kex_exchange_identification: read: Connection reset by peer

3
几天前一切都正常,现在 ssh -T git@gitlab.comssh -T git@github.com 给我相同的输出:kex_exchange_identification: read: Connection reset by peer
我尝试了一些互联网上的建议,但没有成功。我正在使用 Ubuntu 20.04 和 git 版本 2.25.1。 ssh -Tv git@gitlab.com 输出如下:
OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to gitlab.com [172.65.251.78] port 22.
debug1: Connection established.
debug1: identity file /home/fazar/.ssh/id_rsa type 0
debug1: identity file /home/fazar/.ssh/id_rsa-cert type -1
debug1: identity file /home/fazar/.ssh/id_dsa type -1
debug1: identity file /home/fazar/.ssh/id_dsa-cert type -1
debug1: identity file /home/fazar/.ssh/id_ecdsa type -1
debug1: identity file /home/fazar/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/fazar/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/fazar/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/fazar/.ssh/id_ed25519 type -1
debug1: identity file /home/fazar/.ssh/id_ed25519-cert type -1
debug1: identity file /home/fazar/.ssh/id_ed25519_sk type -1
debug1: identity file /home/fazar/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/fazar/.ssh/id_xmss type -1
debug1: identity file /home/fazar/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
kex_exchange_identification: read: Connection reset by peer
1个回答

3
检查你的ssh配置,如gitlab-org/gitlab问题121570中所述。

我发现我的/etc/ssh/ssh_config文件中的端口被意外更改。
一旦我将/etc/ssh/ssh_config中的端口更改回22,我就能连接到Gitlab。

尝试ssh -Tv git@gitlab.com以获取更多信息。 OP Fazar评论中确认,从git 2.25升级到2.33足以解决该问题。
注意:正如这里这里所示,当远程服务器计划维护(或未经计划的维护)时,您也可能会收到那个神秘的错误消息。
因此,请不要忘记检查GitHub状态GitLab状态BitBucket状态或任何其他您用于托管存储库的远程服务。

永远不要更改ssh_config,尝试手动设置端口仍然相同。我编辑了问题以包括详细输出。 - Fazar
@Fazar 你有一个 /.ssh/config 文件吗?你的环境变量中是否有关于 ssh 的任何内容 (env|grep -i ssh)?在 Git 2.33 版本(通过 ppa 升级 后)问题是否仍然存在?你的 `/.ssh/id_rsa.pub` 是否已经注册到你的 GitLab 用户配置的 SSH 设置中? - VonC
@Fazar,是什么改变了你的想法,让你接受了这个答案? - VonC
哦,哇,我把我的 Git 更新到了 2.33.0 版本,它可以正常工作了,感谢您的建议。也许是我不小心更改了一些 Git 配置,而这次更新修复了这个问题。 - Fazar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接