1.根據(jù)郵箱地址生成不同的rsa key
# gitee_id_rsa 保證名字唯一
ssh-keygen -t rsa -C 'xxxxx@company.com' -f ~/.ssh/gitee_id_rsa
2.在 ~/.ssh 目錄下新建一個(gè)config文件誓酒,添加如下內(nèi)容(其中Host和HostName填寫git服務(wù)器的域名融击,IdentityFile指定私鑰的路徑)
$ touch config
3.編輯內(nèi)容 $vi config
# gitee 每個(gè)域名單獨(dú)對應(yīng)一個(gè) key 就算是同一個(gè)郵箱生成的
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
4.用ssh命令測試
ssh -T git@gitee.com
5.復(fù)制key
pbcopy < ~/.ssh/gitee_id_rsa.pub
同域名下配置不同git賬號(hào)
鏈接