1

因为

同一个 ssh-key 不允许在同平台的多个账号当中使用。

但是

我们可以生成多个 ssh-key, 通过 config 来配置 ssh-key 对应的平台与账号。

首先

生成另外的ssh-key

ssh-keygen -t rsa -C "youremail@email.com"

clipboard.png

clipboard.png

此时将提示输入密钥文件名(文件名 = 路径/文件名)

clipboard.png

输入密码,或直接回车,生成 ssh-key

clipboard.png

C:/Users/用户名/.ssh

clipboard.png

然后

如果 ~/.ssh/config 文件不存在,需要创建并设置(无后缀)

clipboard.png

其中 Host 为别名,对应 id_rsa_gitlabHostName 为对应平台

clipboard.png

测试

id_rsa.pub 已经添加到我自己的 gitlab 账号中
id_rsa_gitlab.pub 的内容添加到另外的 gitlab 账号中

clipboard.png

仓库

git remote add origin git@other.github.com:other13398334423/example-project.git   
// 注意: other.github.com


蛋炒太阳
350 声望7 粉丝