234*_*DI8 5 git ssh key tortoisegit gitlab
目前我使用GitLab作为我的远程GIT服务器.
使用分配了SSH密钥的单个Gitlab帐户我没有问题.
但现在我应用了另一个Gitlab帐户,我正在尝试使用相同的SSH密钥,但我无法将密钥添加到这个新帐户.
当我尝试添加密钥时,错误如下:
钥匙已经被采取
指纹已经采取
那么我应该如何使用相同的密钥访问第二个Gitlab帐户呢?如果不可能,我应该如何同时使用两个键.
顺便说一句,我正在使用Windows系统.
提前致谢!!
================================================== =================更新:
下面是我的配置文件.它如下:
#my primary account
Host {account1}
User git
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile C:/Users/{username}/.ssh/id_rsa1
#for NPR_HPTG account
Host {account2}
User git
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile C:/Users/{username}/.ssh/id_rsa2
Run Code Online (Sandbox Code Playgroud)
我有两个Gitlab帐户,
git@gitlab.com:{account_1}/repo1.git
git@gitlab.com:{account_2}/repo1.git
Run Code Online (Sandbox Code Playgroud)
不过,我无法访问account_2.
以前,在我拥有第二个GitLab帐户之前,我只需将ssh密钥上传到account1不需要设置This.但是现在通过这样,仍然,最终我可以推动git@gitlab.com:{account_2}/repo1.git.我正在使用TortoiseGit推/拉.
Von*_*onC 17
只需在%HOME%/.ssh/config文件中声明每个私有ssh密钥:
Host gitlabuser1
User git
Hostname {hostname}
PreferredAuthentications publickey
IdentityFile C:/Users/{username}/.ssh/id_rsa1
Host gitlabuser2
User git
Hostname {hostname}
PreferredAuthentications publickey
IdentityFile C:/Users/{username}/.ssh/id_rsa2
Run Code Online (Sandbox Code Playgroud)
假设您的ssh密钥集是:
%HOME%/.ssh/id_rsa1 ; %HOME%/.ssh/id_rsa1.pub
%HOME%/.ssh/id_rsa2 ; %HOME%/.ssh/id_rsa2.pub
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用克隆/推/拉的URL:
gitlabuser1:yourRepo1
gitlabuser2:yourRepo2
Run Code Online (Sandbox Code Playgroud)
确保您的CMD会话已%HOME%定义,通常是%USERPROFILE%(为您完成git-cmd.bat)
您在此博客文章中有更详细的过程.
| 归档时间: |
|
| 查看次数: |
11845 次 |
| 最近记录: |