当我们频繁操作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
生成**
ssh-****** -t rsa -C "你的github邮箱" #没有的话执行此命令生成公钥和私钥 cat id_rsa.pub #查看公钥并复制
复制**到github
打开github,点击setting >SSH and GPG keys >New SSH key,取个名字,粘贴**即可
验证是否配置成功
ssh -T [email protected] #打开git bash输入此命令,显示successful表示成功
修改hexo的配置文件.config.yml
deploy: #部署部分的设置 type: git repo: [email protected]:你的用户名/你的仓库名.git #设置仓库为ssh格式 branch: master
再次通过hexo g -d 提交博客代码时就不用输入密码了