情况
ex exchange identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 22
问题分析
github.com可以ping通,证明网络层是通的
查看本地~/.ssh路径下有ssh的私钥和公钥,github上面已经提交ssh的公钥,但是测试和github的ssh登录情况却报错(端口无论是443还是22都被拒绝)
ssh -T git@github.com
报错情况如图
原因
导致远程主机拒绝连接的原因可能有两种:
- 本地代理(vpn)影响
- SSL验证问题
解决方法
-
本地代理原因(7890是代理的端口,注意查看自己的端口是不是这个)
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890 -
SSL验证原因
git config --global http.sslBackend "openssl"
git config --global http.sslCAInfo "C:\Program Files\Git\mingw64\ssl\cert.pem"