在同一台电脑使用多个github账号发布多个hexo博客

Step 1

生成第二个key,取名作id_rsa_second,并将key添加到第二个github账户中

# Generate new ssh keys
$ cd ~/.ssh
# You should see there is already a ssh key, id_rsa.pub
$ ssh-keygen -t rsa -C "[email protected]"
·
# Give your second ssh key another name: e.g., id_rsa_second
Generating public/private rsa key pair.
Enter file in which to save the key (c/Users/zhuyi/.ssh/id_rsa):
$ id_rsa_second

Step 2

将第二个key添加入代理

$ ssh-add ~/.ssh/id_rsa_second

如果执行失败可以尝试

$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa_second

Step 3

~/.ssh找到config文件,如果没有就自己添加一个,在config文件里添加

# Default Github User ([email protected])
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa

# Second Github User ([email protected])
Host git2   
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_second
# git2 is the alternative name of your second Github account, you can use it when you clone or update your project. Details can be found later.

Step 4

前往你的第二个hexo博客地址,修改_config.yml配置

deploy:
  type: git
  repo: git2:xxx/xxx.github.io.git
  branch: master

添加完尝试执行hexo ghexo d即可。

你可能感兴趣的:(在同一台电脑使用多个github账号发布多个hexo博客)