Hexo上传github


当初小白,辖研究终于搞定了hexo上传github。今天发表文章的时候,github
官方提醒我输入密码上传的服务在8/31号之后终止。慌的一笔,只好研究怎么可以不用密码,直接用电脑生成的密钥进行上传。所有操作均是在虚拟机ubuntu系统上完成。

打开终端

$ cd ~/.ssh

使用 ssh-keygen 生成密钥

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

这里设定密码两次

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

密钥生成成功

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

进入自己的github网站
首页菜单栏中点击 Settings –> SSH and GPG keys –> Add SSH key,然后将生成的 id_rsa.pub 中的内容全选复制到 key 输入框中,然后点击 Add key 完成添加公钥。

这里如果要查看自己的私钥进行下列操作

cd ~/.ssh
ls
cat id_rsa.pub

将命令后显示的内容全部复制到add key的页面框内即可。

测试配置是否成功

$ ssh -T git@github.com

更改hexo 配置文件

deploy:
  type: 'git'
  repository: git@github.com:YXY996/yxy996.github.io.git
  branch: main

大功告成,撒花。


评论
  目录