- 进入ssh目录:
cd ~/.ssh
- 创建新的ssh key:
ssh-keygen -t rsa -C "[email protected]"
后续提示内输入name: id_rsa_tiger
- 创建config文件:
touch config
配置config:
# github
Host git
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
# github tiger
Host git2
HostName github.com
PreferredAuthentications publickey
User [email protected]
IdentityFile ~/.ssh/id_rsa_tiger
- 添加密钥:
ssh-add ~/.ssh/id_rsa_tiger
- 到要用git2的仓库修改其git配置:
git config user.email "[email protected]"
git config user.name "tigerHee"