侧边栏壁纸
博主头像
TLSOU-特来搜分享 博主等级

特来搜,全网优质资源分享......

  • 累计撰写 31 篇文章
  • 累计创建 51 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

如何同时将hexo部署到github和个人ubuntu服务器

特来搜
2025-03-04 / 0 评论 / 0 点赞 / 17 阅读 / 0 字 / 正在检测是否收录...

如何同时将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

5.尝试部署,注意看是否部署两次,即可判定是否成功。

6.至此成功解决问题,这个问题都花了好几个小时才解决。记录一下,以备不时之需。

0

评论区