wget raw.githubusercontent.com Unable to establish SSL connection 无法建立SSL连接 解决方法
warning:
这篇文章距离上次修改已过782天,其中的内容可能已经有所变动。
用wget下载github上面文件的时候经常会发生Unable to establish SSL connection的情况,例如:
[root@localhost ~]# wget https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json
--2020-12-17 09:44:41-- https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.228.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.228.133|:443... connected.
Unable to establish SSL connection.
一般情况下,在命令后面加上--no-check-certificate
不验证ssl证书即可解决,但是有时候加了参数还是不行。
wget https://raw.githubusercontent.com/cppla/ServerStatus/master/autodeploy/config.json --no-check-certificate

由于众所周知的原因,raw.githubusercontent.com的域名解析已被污染,无法访问。
除了挂上代理访问之外,还有个方法就是修改hosts
解决问题。
获取真实ip
进入IPAddress这个网站,在搜索框内输入raw.githubusercontent.com
即可查询真实IP地址。

下一步,修改hosts
Linux
以管理员权限打开hosts文件vim /etc/hosts
,在里面加入以下内容
199.232.96.133 raw.githubusercontent.com
Windows
以管理员权限打开C:WindowsSystem32driversetc目录下的hosts文件,在里面加入以下内容即可
199.232.96.133 raw.githubusercontent.com
然后,再次运行wget命令,即可正常下载github文件了
好用的唯一方法就是真实ip