1. hexo博客无法上传
2.0 现象
使用
hexo d上传博客时发现无法上传,显示1
2ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.使用
git push却可以上传- 因为
git push使用的时https,而hexo d使用的是ssh
- 因为
2.1 测试
1 | ssh -T git@github.com |
- 原因: 在国内/公司/学校等网络环境下,
github.com:22常被阻断,导致连接超时 - GitHub 官方提供了
ssh.github.com(可以使用端口 22 或 443)用来替代github.com:22
2.2 解决
1)方案1
在
user/username/.ssh/config中添加:1
2
3
4
5Host github.com
HostName ssh.github.com
Port 22
User git
IdentityFile ~/.ssh/id_rsa
2)方案2
将
_config.yml中的deploy的repo部分修改:- 使用https协议
1
2
3repo: git@github.com:lankeren035/lankeren035.github.io.git
改成
repo: https://github.com/lankeren035/lankeren035.github.io.git- 使用
ssh.github.com
1
2
3repo: git@github.com:lankeren035/lankeren035.github.io.git
改成
repo: ssh://git@ssh.github.com:22/lankeren035/lankeren035.github.io.git