github connection timed out

在执行 hexo -d 的时候,这个报错不陌生吧……

1
Failed to connect to github.com port 443: Timed out

github 连接超时。

曾经在 windows 电脑上,这个办法还挺有用……就是在 git config 上面倒腾来倒腾去……

1
2
git config --global http.proxy http://[github username]:[github passwords]@127.0.0.1:1080
git config --global https.proxy http://[github username]:[github passwords]@127.0.0.1:1080

或者

1
2
git config --global --unset https.proxy
git config --global --unset http.proxy

这个办法非常不稳定,能不能解决都是概率问题……
如今发现,最稳定的方式是配置 github 远程仓库的地址为 ssh 的地址。

查看 ssh 是否成功连接 github

1
2
(base) huangsisi@huangsisis-Air hexo-22 % ssh -T git@github.com
Hi Hc1023! You've successfully authenticated, but GitHub does not provide shell access.

这样子表示是成功连接的,否则需要进行密钥配置。修改博客根目录的配置文件如下,repo 不要用 https 开头的!

1
2
3
4
deploy:
type: git
repo: git@github.com:[USERNAME]/[USERNAME].github.io.git
branch: master