MAC给Git配置多个SSH Key

1.查看有SSH Key吗。

cat ~/.ssh/id_rsa.pub

2.拷贝SSH KEY

pbcopy < ~/.ssh/gitee_id_rsa.pub
pbcopy < ~/.ssh/id_rsa.pub

3.创建gitee的key,或者其他key

除了默认的id_rsa.pub 如果还需要添加一个gitee的SSH Key

1.ssh-keygen -t rsa -C 'xxxxx@youremail.com' -f ~/.ssh/gitee_id_rsa生成一个Gitee的SSH Key 生成一个gitee的key.

ssh-keygen -t rsa -C 'aofeilin@163.com' -f ~/.ssh/gitee_id_rsa

2.拷贝SSH KEY 到gitee代码的平台。头像-设置-SSH公钥。
3.touch ~/.ssh/config 在~/.ssh文件夹下添加config文件

在config中指定key.

#gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
4.使用以下命令分别测试GitHub和Gitee,查看SSH Key是否添加成功。

ssh -T git@gitee.com
ssh -T git@github.com

参考:

https://gitee.com/help/articles/4229#article-header0

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容