Git问题:解决“ssh:connect to host github.com port 22: Connection timed out”


Git问题:解决“ssh:connect to host github.com port 22: Connection timed out”

学习Git的时候,遇到的一个小麻烦,困扰了我两天,终于解决,在此记录,其中的原理还需慢慢探索

操作系统 Windows10
使用 cmder 命令行
连接方式:SSH

在使用:ssh -T git@github.com来测试git是否成功连接github的时候

$ ssh -T git@github.com

ssh: connect to host github.com port 22: Connection timed out

本以为是命令行使用git的问题,在命令行代理问题中方面找了很久,最后通过配置hosts访问GitHub,顺利解决了问题

期间还配置了很多次.ssh文件夹中的config,完全没啥作用

hosts文件路径

C:\Windows\System32\drivers\etc\hosts

添加hosts配置

140.82.112.3 github.com
140.82.114.4 gist.github.com
185.199.108.153 assets-cdn.github.com
199.232.68.133 raw.githubusercontent.com
199.232.68.133 gist.githubusercontent.com
199.232.68.133 cloud.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com

期间有使用 Proxifier 这个软件,本以为是软件的配置问题,现在想来,似乎和这个软件没啥关系,之后可以用此软件加速git clone,对于ssh而言,这个软件的代理并没有问题

本文参考自:

配置hosts快速访问GitHub

ssh连接失败,排错经验

git上传代码报错ssh: connect to host github.com port 22: Connection timed out解决办法

github默认端口22被占用,ssh: connect to host github.com port 22: Connection timed out

Solution for 'ssh: connect to host github.com port 22: Connection timed out' error


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM