为本地配置多个ssh key
介绍
给github和gitlab配置上不同的公钥对。
方案
生成key
ssh-keygen -t rsa -f C:/Users/ff/.ssh/github_rsa -C "github"
ssh-keygen -t rsa -f C:/Users/ff/.ssh/gitlab_rsa -C "gitlab"
增加到远程
把~/.ssh/github_rsa.pub
的内容复制到
https://github.com/settings/keys
同理把gitlab_rsa.pub公钥也复制到gitlab上去
https://gitlab.com/profile/keys
如果 机器的话
增加到.ssh/authorized_keys
中
配置 config
在.ssh/
目录下新建config,内容如下
1 |
|
测试
ssh -T git@github.com
ssh -T git@gitlab.com
参考
http://riny.net/2014/git-ssh-key/
https://my.oschina.net/stefanzhlg/blog/529403
2017_09_07 更新
如果遇每个仓库的用户不一样,邮箱也不一样。
就要取消全局的username和email改为每个项目设置一个
1 |
|
为本地配置多个ssh key
https://blog.fengcl.com/2017/06/06/config-multiple-ssh-key/