参考文献
1.ssh-keygen 中文手册-金步国
2.Windows下Git多帐号配置,同一电脑多个ssh-key的管理-popfisher
3.hexo同时托管到coding.net与githubhtml
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f 'id_rsa_coding'
其中:
ssh-keygen - 生成、管理和转换认证密钥
-t type 指定要建立的密钥类型。可使用:"rsa1"(SSH-1) "rsa"(SSH-2) "dsa"(SSH-2)
-b bits 指定密钥长度
-C comment 提供一个注释
-f filename 指定密钥文件名git
在帐户-ssh公钥
处新增生成的私钥对应的公钥id_rsa_coding.pub
github
coding.net多帐户configsegmentfault
在~/.ssh
文件夹下新建config文件,写入下列内容bash
Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa User chrisji0518@outlook.com Host git.coding.net User chrisji0518@outlook.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_coding
其中:
Host 别名
HostName 主机名
User 用户名
IdentityFile 密钥文件路径hexo
分别测试github和coding.net是否能够链接ssh
ssh -T git@github.com
ssh -T git@git.coding.net
利用git remote add
分别命名,在分别push测试
git remote add github 仓库地址 git remote add coding 仓库地址 ... git push github master git push coding master