Hexo Deploy Without Password

unsplash

This articles talks about how to deploy hexo blog to hexo page services without enter username and password.

The key process is to config hexo _config.yml, and change the deploy segement.

1
2
3
4
deploy:
type: git
repo: git@github.com:username/repository-name.github.io.git
branch: master

For more details, step below:

Preface

I assume all the readers have a well configured hexo, and can deploy to Github with typing username and passwords.

Then the below 2 steps for how to deploy without username/passwords.

Generate a ssh key

Commands to generate a ssh key is through ssh-keygen, like below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ylo/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ylo/.ssh/id_rsa.
Your public key has been saved in /home/ylo/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Up6KjbnEV4Hgfo75YM393QdQsK3Z0aTNBz0DoirrW+c ylo@klar
The key's randomart image is:
+---[RSA 2048]----+
| . ..oo..|
| . . . . .o.X.|
| . . o. ..+ B|
| . o.o .+ ..|
| ..o.S o.. |
| . %o= . |
| @.B... . |
| o.=. o. . . .|
| .oo E. . .. |
+----[SHA256]-----+

Then copy content from the generated file ~/.ssh/id_rsa.pub to GitHub.

Config Hexo

After config ssh key to Github, need to change the deploy part in _config.yml like below:

1
2
3
4
deploy:
type: git
repo: git@github.com:username/repository-name.github.io.git
branch: master

while the original content is:

1
2
3
4
deploy:
type: git
repo: https://github.com/username/repository-name.github.io.git
branch: master
0%