1.在GitHub上新增一個repository
新建倉庫的配置信息如下:
定義GitHub Pages域名
此時我們訪問這個網址將會顯示readme文件信息
https://html1211.github.io/
GitHub添加ssh-key
[root@iZwz93tzhqv97y8089coonZ ~]# ssh-keygen -t rsa #需要輸入的地方直接Enter即可
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:S4lmg3k4y7ei2QgK8aSxR7866vEo8EviRnUgBLfGXkE root@iZwz93tzhqv97y8089coonZ
The key's randomart image is:
+---[RSA 2048]----+
|+...E |
| + o . |
| = o |
| o o = . . |
|o = * * S |
|.X o * o . |
|Oo+ + . . |
|=**+.o . |
|*=**o.. |
+----[SHA256]-----+
[root@iZwz93tzhqv97y8089coonZ ~]# cd .ssh
[root@iZwz93tzhqv97y8089coonZ .ssh]# ls
authorized_keys id_rsa id_rsa.pub
[root@iZwz93tzhqv97y8089coonZ .ssh]# ll
total 8
-rw------- 1 root root 0 Feb 15 12:04 authorized_keys
-rw------- 1 root root 1675 Feb 15 20:58 id_rsa
-rw-r--r-- 1 root root 410 Feb 15 20:58 id_rsa.pub
[root@iZwz93tzhqv97y8089coonZ .ssh]# cat id_rsa.pub #查看公鑰內容
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3z1vmc/Fgzbhk+Ubkbi1KvN6ovHhsuBmGVZRclBDhkWaYX23Psre1dn9mJsQv5n1y1LjkPLtliaaYROBRFCzHDSVQQSLVvG1OIMGtYAD1FIiUf3Sy2Of3UxSRMFVbTaFJCg7STV6QIyigPeJq5xHeuHh4BpIZRajzex9Vqprv3hyjcT46F547Zpl3pzPvBuEuoA5xJIQ4cG5JzWbmgLFvMBvMG0labxvYFbWZJeUBxUx55wacOpP/NhzqM46Ihrw2S11+JDDrwqE9rRZyRKeZ9xqmdTvQL594AA3h6f+w1UBj6LG1f32YaeQyXD5PNPZE+XiDMwP4IFh345/9rCW/ root@iZwz93tzhqv97y8089coonZ
服務器通過ssh連接GitHub
服務器成功連接GitHub信息如下
[root@iZwz93tzhqv97y8089coonZ /]# ssh -T [email protected]
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi html1211! You've successfully authenticated, but GitHub does not provide shell access.
設置服務器Git賬戶
賬戶和郵箱均需與GitHub保持一致
[root@iZwz93tzhqv97y8089coonZ /]# git config --global user.name "html1211"
[root@iZwz93tzhqv97y8089coonZ /]# git config --global user.email "[email protected]"
修改hexo站點配置文件,配置hexo默認git提交倉庫
打開站點配置文件_config.yml
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: [email protected]:html1211/html1211.github.io.git
branch: master
hexo部署環境需要hexo-deployer-git
插件
[root@iZwz93tzhqv97y8089coonZ hexo]# npm install hexo-deployer-git --save
部署hexo到GitHub
[root@iZwz93tzhqv97y8089coonZ hexo]# hexo d -g # -g可選,表示生成靜態網頁
瀏覽器訪問
https://html1211.github.io/ #GitHub Pages訪問
http://服務器公網ip/ #個人網站訪問
http://服務器域名/ #個人網站訪問