如何同时将hexo部署到github和个人ubuntu服务器
参考成品:https://eystasy.github.io/
1、申请秘钥对的时候需要指定位置和名称
ssh-keygen -t rsa -C "eystasy@gmail.com" -f C:\Users\Colar\github\my_ssh_key
说明:
-t 表示选择加密方式。
-c 表示用户,通常填写邮箱表示
-f 指定秘钥保存路径,最后的“my_ssh_key”表示秘钥名称
2、用notepad等软件打开.pub的公钥,复制后粘贴到github的SSH key的位置。具体见图。
3.配置config文件
路径:C:\Users\Colar\.ssh
config配置
Host github.com
HostName github.com
User git
IdentityFile C:\\Users\\Colar/github/my_ssh_key
IdentitiesOnly yes
-
将
C:/path/to/your/private_key
替换为你的私钥文件的实际路径。注意路径使用正斜杠(/)或双反斜杠(\)。 -
Host
可以是任何你想要的别名,如果你连接的是GitHub,通常直接使用github.com
。 -
HostName
是Git服务器的地址,对于GitHub,它就是github.com
。 -
User
是SSH连接中使用的用户名,对于GitHub而言,通常是git
。 -
IdentitiesOnly yes
确保SSH只使用指定的IdentityFile
。 -
运行下列代码检测连通性:
-
ssh -T git@github.com
或者下面的代码(区别是有错误输出):
ssh -vT git@github.com
4.hexo中的_config主文件中进行相关修改
deploy:
- type: git
repo:
branch:
- type: heroku
repo:
branch:
因为我是用的nginx proxy manager管理网站,所以同时采用了git链接和ssh链接,附上个人部署方案:
deploy:
- type: git
repo: ssh://root@111.111.111.111:/home/git/blog
branch: master
- type: git
repo: git@github.com:Eystasy/eystasy.github.io.git
branch: master
评论区