SSH connect to host github.com port 22 - Connection refused
文章目录
SSH connect to host github.com port 22 - Connection refused
问题
Windows系统,在个人电脑上使用Git命令操作GitHub上的仓库,突然提示错误:
ssh: connect to host github.com port 22: Connection refused
。
例如:
|
|
解决方法
使用GitHub的443端口
22
端口可能被防火墙屏蔽了,可以尝试连接GitHub的443
端口。
|
|
该解决思路是:给~/.ssh/config
文件里添加如下内容,将ssh
连接GitHub的端口更改为443
。
|
|
注:如果
~/.ssh
目录下没有config
文件,新建一个即可。Windows操作方法类似。
修改完~/.ssh/config
文件后,使用ssh -T git@github.com
来测试和GitHub的网络通信是否正常,如果提示Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
就表示一切正常了。
这个方案有效的前提是: 执行命令ssh -T -p 443 git@ssh.github.com
后不再提示connection refused
,所以要尝试这个方案可先执行这条命令测试下。
文章作者 Long He
上次更新 2024-09-05