ssh配置
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
输入密钥的title,可自定义输入,下面的key的内容即为刚才生成的密钥内容,将其复制粘贴进去(可能会遇到问题,请继续往后看),后点击add ssh key即可创建成功
3.测试配置是否成功
ssh -T git@GitHub.com
如果看到successfully,即为配置完成并且成功
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.部署推送到远程仓库
ub.com:looles/looles.github.io.git
branch: master
#### 6.部署推送到远程仓库
转载于: 2021-01-03-设解决使用hexo deploy推送代码到github仓库时重复输入账户密码
注意事项
1、如果之前设置过ssh,但是部署的时候需要输入密码,可能是没有配置好,用
ssh -T git@GitHub.com
检查的时候需要输入密码,则代表没有配置好。建议重头配置一次,提示是否要overwrite的时候y就行了。
2、另外粘贴密钥的时候可能会遇到问题 “Key is invalid. You must supply a key in OpenSSH public key format github”,请继续往后看。
add ssh key报错
直接复制粘贴 .ssh的文件会破坏格式
需要打开 git bash
输入命令clip < ~/.ssh/id_rsa.pub
回车后就复制到剪切板了,到github添加ssh keys的地方直接就能粘贴上
如图:
转载于:Key is invalid. You must supply a key in OpenSSH public key format github
以上就完成了对hexo deploy的所有配置。