解决使用hexo deploy推送代码到github仓库时重复输入账户密码


解决使用hexo deploy推送代码到github仓库时重复输入账户密码

1.生成SSH密钥

cd ~/.ssh

使用ssh -Keygen 生成密钥

ssh-keygen -t rsa -C "your_email@example.com"

后面的输入均使用默认值,点击enter回车跳过

密钥生成成功

Your identification has been saved in /home/you/.ssh/id_rsa.
Your public key has been saved in /home/you/.ssh/id_rsa.pub.
The key fingerprint is:
…………………此处是密钥内容…………………… your_email@example.com

点击复制

2.设置GitHub仓库的密钥

点击SSh and GPG keys,后新建一个SSh key

image-20210103194924377

输入密钥的title,可自定义输入,下面的key的内容即为刚才生成的密钥内容,将其复制粘贴进去,后点击add ssh key即可创建成功

image-20210103195020682

3.测试配置是否成功

ssh -T git@GitHub.com

如果看到successfully,即为配置完成并且成功

image-20210103195309236

4.修改博客Git远程提交的地址

# 修改 https 协议为 ssh 协议(仓库的ssh地址)
git remote set-url origin git@github.com:xxx/xxx.git

5.修改hexo根目录下的_config.yml文件中的远程仓库设置

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repository: git@github.com:looles/looles.github.io.git
  branch: master

6.部署推送到远程仓库


文章作者: Loole
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Loole !
评论
  目录