參考文獻
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