Git配置多个SSH-Key
software
2020-03-11 11:25
1、生成 gitee SSH-Key;
$ ssh-keygen -t rsa -C 'git@gitee.com' -f ~/.ssh/gitee_id_rsa
2、生成 github SSH-Key;
$ ssh-keygen -t rsa -C 'git@github.com' -f ~/.ssh/github_id_rsa
3、添加配置文件,在 ~/.ssh 目录下新建一个 config 文件;
# gitee
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 -T git@gitee.com
$ ssh -T git@github.com
内容摘自:gitee.com