同一平台下多个账号配置ssh

以coding.net为例,有两个账号:coding_1 和 coding_2。

第一步:为两个账号分别生成密钥,用以下命令

ssh-keygen -t rsa -C "Your_Email" -f ~/.ssh/coding_1

ssh-keygen -t rsa -C "Your_Email" -f ~/.ssh/coding_2

这样就生成了coding_1.pub 和 coding_2.pub两个密钥了,分别添加到平台账号上去。

第二步:修改config配置

vim ~/.ssh/config

按照下面示例修改

host coding_first    //coding_first可以随意更换

hostname git.coding.com

user username    //这一行可以不用配置

IdentityFile ~/.ssh/coding_1

同理添加第二个:

host coding_second

hostname git.coding.com

IdentityFile ~/.ssh/coding_2

第三步:使用

比如原来的URL是:git@git.coding.com/***.git

需要修改为git@coding_first/***.git

测试命令:

ssh -T git@coding_first

如果出现Hello.....就大功告成了。

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

推荐阅读更多精彩内容