其實都是大同小異,關鍵是不一樣的庫生成不一樣的key-pair,並配置config保證找到正確的私鑰:git
ssh-keygen -t rsa -C "test@gmail.com" // 注意修改key-pair的名字 ssh-add -K ~/.ssh/id_rsa // 我試下來彷佛不用加到ssh-agent裏? ssh-add -K ~/.ssh/id_rsa_projectName ssh-add -l
編輯~/.ssh/config,保證ssh在push的時候能找到正確的私鑰
```
vi ~/.ssh/configgithub
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
#ProxyCommand=nc -X 5 -x localhost:1086 %h %pssh
Host projectName.github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_projectNamegitlab
git clone git@projectName.github.com:UserName/projectName.git //新clone時 或者修改項目中的.git/config文件 [remote "origin"] url = git@projectName.github.com:UserName/projectName.git