git 配置多个.ssh
同一台电脑配置多个.ssh 执行多个平台例如 gitee github gitlab … 等等平台
解决方法
1.生成一个gitee秘钥
~/.ssh/gitee_id_rsa 是秘钥的生成的地址 ~写绝对路径 例如 C:\Users\admin.ssh/id_rsa_github
$ ssh-keygen -t rsa -C 'xxxxx@company.com' -f ~/.ssh/id_rsa_gitee
$ ssh-keygen -t rsa -C "2972677157@qq.com" -f C:\Users\admin\.ssh\id_123
2.生成一个github用的SSH-Key
$ ssh-keygen -t rsa -C 'xxxxx@qq.com' -f ~/.ssh/id_rsa_github
3.在 .ssh 目录下新建一个config文件,添加如下内容(其中Host和HostName填写git服务器的域名,IdentityFile指定私钥的路径)
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
4.用ssh命令分别测试
$ ssh -T git@gitee.com
$ ssh -T git@github.com
出现这样的代表成功了