如何为我的新gitlab帐户生成新的ssh-key?
我有两个 gitlab帐户,它位于〜/ .ssh中旧帐户中添加了 ssh-key /id_rsa.pub 在我的电脑中,
现在我要为新的gitlab帐户添加另一个ssh-key 。
I have two gitlab account, which in my old account added an ssh-key that located in ~/.ssh/id_rsa.pub in my pc,
now I want added another ssh-key for my new gitlab account.
如果没有 ssh-keys冲突或者类似的东西,我该如何做?
How do I it, without ssh-keys conflict or some things like this?
我会推荐第二个密钥,现在不用密码:
I would recommend a second key, for now without passphrase:
ssh-keygen -t rsa -C "your_email@example.com" -P "" -q -f ~/.ssh/gitlab_rsa
这将创建(没有任何提示)〜/ .ssh / gitlab_rsa
(私钥)和〜/ .ssh / gitlab_rsa.pub
(公钥)
That will create (without any prompt) ~/.ssh/gitlab_rsa
(private key) and ~/.ssh/gitlab_rsa.pub
(public key)
您需要注册第二个 gitlab_rsa.pub
公钥到你的第二个GitLab帐户。
$ b
You need to register that second gitlab_rsa.pub
public key to your second GitLab account.
导航到'SSH Keys'配置文件设置。将你的钥匙粘贴在'钥匙'部分,并给它一个相关的'标题'。
然后添加一个〜/ .ssh / config
文件:
Host gitlab_rsa
HostName gitlab.com
User git
PreferredAuthentications publickey
IdentityFile /home/<you>/.ssh/gitlab_rsa
最后,您可以将任何GitLab回购第二种身份与:
Finally, you can clone any GitLab repo as your second identity with:
git clone gitlab_rsa:<yourSecondAccount>/<yourRepo.git>
这将被 git@gitlab.com自动替换:< yourSecondACcount> ; /< yourRepo.git>
并将使用第二个键。
That will be replaced automatically with git@gitlab.com:<yourSecondACcount>/<yourRepo.git>
and will use your second key.