当我们频繁操作GitHub的时候,经常需要输入密码来验证,为了简化我们的put、pull的过程和安全,我们需要设置SSH Key

 

设置全局变量

查看Git环境所有配置

git config --list

如果没有配置user.name和user.email则需要先配置

git config --global user.name "用户名随意"
git config --global user.email  "[email protected]" #填写github注册的邮箱

查看SSH Key

cd ~/.ssh 
ls 

Hexo使用SSH连接GitHub

生成**

ssh-****** -t rsa -C "你的github邮箱" #没有的话执行此命令生成公钥和私钥
cat id_rsa.pub #查看公钥并复制

Hexo使用SSH连接GitHub

复制**到github

打开github,点击setting >SSH and GPG keys >New SSH key,取个名字,粘贴**即可

Hexo使用SSH连接GitHub

验证是否配置成功

ssh -T [email protected] #打开git bash输入此命令,显示successful表示成功

Hexo使用SSH连接GitHub

修改hexo的配置文件.config.yml

deploy:   #部署部分的设置
  type: git
  repo: [email protected]:你的用户名/你的仓库名.git  #设置仓库为ssh格式
  branch: master 

再次通过hexo g -d 提交博客代码时就不用输入密码了

相关文章:

  • 2022-02-10
  • 2021-10-16
  • 2021-11-08
  • 2021-10-05
  • 2021-10-03
  • 2021-11-27
  • 2022-02-23
  • 2022-12-23
猜你喜欢
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-07-28
相关资源
相似解决方案