0%

hexo deploy——避免重复输入账户密码

ssh配置

1.生成SSH密钥

cd ~/.ssh

  • 1
  • 使用ssh -Keygen 生成密钥

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

  • 1
  • 后面的输入均使用默认值,点击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
    

  • 1
  • 2
  • 3
  • 4
  • 点击复制

    2.设置GitHub仓库的密钥

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

    image-20210103194924377

    输入密钥的title,可自定义输入,下面的key的内容即为刚才生成的密钥内容,将其复制粘贴进去(可能会遇到问题,请继续往后看),后点击add ssh key即可创建成功

    image-20210103195020682

    3.测试配置是否成功

    ssh -T git@GitHub.com
    

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

    image-20210103195309236

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

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

  • 1
  • 2
  • 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
    

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 6.部署推送到远程仓库

    ub.com:looles/looles.github.io.git
    branch: master

    
    #### 6.部署推送到远程仓库
    
    

  • 1
  • 2
  • 3
  • 转载于: 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的所有配置。