SSH-KEY多平台对多帐号

由于

同一个 ssh-key 不容许在同平台的多个帐号当中使用。git

可是

咱们能够生成多个 ssh-key, 经过 config 来配置 ssh-key 对应的平台与帐号。github

首先

生成另外的ssh-keyssh

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

clipboard.png

clipboard.png

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

clipboard.png

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

clipboard.png

C:/Users/用户名/.sshspa

clipboard.png

而后

若是 ~/.ssh/config 文件不存在,须要建立并设置(无后缀)code

clipboard.png

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

clipboard.png

测试

id_rsa.pub 已经添加到我本身的 gitlab 帐号中
id_rsa_gitlab.pub 的内容添加到另外的 gitlab 帐号中ip

clipboard.png

仓库

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

相关文章
相关标签/搜索