如何为我的新gitlab帐户生成新的ssh-key? [英] How do I generate new ssh-key for my new gitlab account?

查看:732
本文介绍了如何为我的新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.

这篇关于如何为我的新gitlab帐户生成新的ssh-key?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆