1.1 清除原有 git 的全局配置
$ git config --global --list
![image-20220220204533366](https://img-blog.csdnimg.cn/img_convert/c7df7fdc71186b39f14438c85385e4f9.png)
$ git config --global --unset user.name "chenlan"
$ git config --global --unset user.email "739904595@qq.com"
1.2 生成 ssh keys
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "739904595@qq.com"
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "739904595@qq.com"
![image-20220220220856](https://img-blog.csdnimg.cn/img_convert/907103e14dde48ed65089040b6750de3.png)
1.3 将私钥添加到 ssh agent 中
$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa.github
$ ssh-add ~/.ssh/id_rsa.gitee
1.4 配置 config 文件
$ touch ~/.ssh/config
![image-20220220220019828](https://img-blog.csdnimg.cn/img_convert/e0a6a994b52083313735141dc148d9d1.png)
# gitHub
Host github.com
HostName github.com
User chenlan
IdentityFile ~/.ssh/id_rsa.github
# gitee
Host gitee.com
HostName gitee.com
User chenlan
IdentityFile ~/.ssh/id_rsa.gitee
1.5 添加 ssh key
Setting -> SSH and GPG keys -> NEW SSH key
![image-20220220231055226](https://img-blog.csdnimg.cn/img_convert/9769eb1bcf355083a7acf65f31de0c5d.png)
|