由于公司使用的是gitlab,会使用ssh-keygen 生成rsakey,同时使用github的时候也要生成rsa-key,针对这种情况,在生成key的时候,难免会产生覆盖:12Generating public/private rsa key pair.Enter file in which to save the key (/Users/Wicky/.ssh/id_rsa):
针对这种情况,我们在生成key的时候指定生成id_rsa_github和id_rsa_github.pub,和id_rsa、rd_rsa.pub区分开,将id_rsa_github.pub 的内容填入github的SSH Key中即可。
最后在 ~/.ssh/ 中创建config文件,加上以下几行代码:1234567891011# gitlabHost gitlab.com HostName gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa# github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_github
输入 ssh -T git@github.com 测试
测试OK即可