系统环境:ubuntu18.04

 

1.设置SSH

cd ~/.sh 
sudo ssh-keygen -t rsa -C "你的注册邮箱" #生成ssh
# 然后连按三下回车

sudo gedit id_rsa.pub #打开id_rsa.pub文件,并把内容复制到剪切板

 登录到github打开设置;

选择SSH and GPG keys,点New SSH

然后配置SSH,点击Add SSH key完成。

 

2.配置SSH

cd ~/.ssh #进入ssh目录
sudo touch config #新建ssh的配置文件
sudo gedit config #修改ssh的配置文件
sudo chmod 600 config #添加权限

config文件的内容:

Host github.com  
User 你的注册邮箱 
Hostname ssh.github.com  
PreferredAuthentications publickey  
IdentityFile ~/.ssh/id_rsa  
Port 443

测试

sudo ssh git@github.com

看到如下图,说明配置成功

3.修改_config.yml

修改deploy下的repo属性

deploy:
  type: git
  repo: git@github.com:你的name/你的username.github.io.git
  branch: master

 

参考博客:

https://zhuanlan.zhihu.com/p/26625249

https://blog.csdn.net/MBuger/article/details/70226712

https://blog.csdn.net/hhgggggg/article/details/77853665