14

解决 SSH 连接 GitHub 出现 Connection Closed

 1 year ago
source link: https://paugram.com/tech/github-ssh-connection-closed-problem-with-proxy.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

解决 SSH 连接 GitHub 出现 Connection Closed

2023.05.15做个技术宅 0 35

GitHub 早期已经禁止使用 HTTPS 的方式提交代码了,因此我改用 SSH 的方式连接仓库。近期在公司使用第三方代理服务时发现多个节点均不能正常使用,我起初还怀疑是 SSH 密钥配置的问题,结果 GitHub 显示我并没有使用新的密钥连接过...

具体错误信息如下:

kex_exchange_identification: Connection closed by remote host
Connection closed by 198.18.0.15 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

公司还有一个自建的代理服务,之前使用它提交代码到 GitHub 一直都正常,但由于近期公司的移动网络不太稳定,一直连接超时不可用(联通则正常),才不得不思考其他办法。

尝试了其他代理服务商提供的节点,依旧不可用。我怀疑是服务商做的限制,就让公司对应账号所有者问了下客服。结果是服务商禁用了 22 端口(连接 SSH 服务默认均为 22 端口),替换为 443 即可。

简单阅读完这篇文章后,由于我在多个站点配置了多个 SSH 密钥,所以直接选择了它修改 config 的操作,成功解决以上问题。

# GitHub
Host github.com
Port 443
User git
HostName ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_ed25519

至于为什么前面提到的公司自建的代理服务可用,估计是他们没做任何奇怪的限制吧。反过来那些公开使用的,自然是需要做一些安全保护了。

Paul

特立独行的一只前端菜狗。本站未注明转载的文章均为原创,并采用 CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢!如本站内容对你有所帮助的话,不妨 捐助支持 一下?同时欢迎订阅关注 我的日记,唠嗑(分享)每日的折腾经历。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK