同一平台下多个账号配置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是:[email protected]/***.git

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

测试命令:

ssh -T git@coding_first

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

你可能感兴趣的:(同一平台下多个账号配置ssh)