挂代理后 git clone 出现 Connection closed by xxxxxxx port 22 的解决办法

约 1 分钟 #开发
杨秋逸
杨秋逸

出现这个问题,往往是因为代理的防火墙拒绝了 SSH 连接,可以尝试使用在 HTTPS 端口上建立的 SSH 连接进行克隆。

参考:https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port

解决方案

~/.ssh/config 里添加:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git