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 "yourSecondEmail@email.com"
·
# 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 (yourFirstEmail@mail.com)
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
# Second Github User (yourSecondEmail@mail.com)
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 g
、 hexo d
即可。