Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
892 views
in Technique[技术] by (71.8m points)

git - How to set up two SSH keys for two GitLab accounts and push/pull by using TortoiseGit?

Currently I'm using GitLab as my remote GIT server.
I have no problem using single Gitlab account with SSH key assigned to it.

But now I applied another Gitlab account and I'm trying to use the same SSH key for it, but I cannot add the key to this new account.
The error is as follows when I tried to add the key:

Key has already been taken
Fingerprint has already been taken

So how should I use the same key to access the second Gitlab account? if it is not possible, how should I use two keys at the same time.

By the way, I'm using windows system.

Thanks in advance!!

Updates

Below is my config file. And it is as follows:

#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

And I'm having two Gitlab account,

git@gitlab.com:{account_1}/repo1.git
git@gitlab.com:{account_2}/repo1.git

Still, I cannot access to the account_2.

Previously, before I'm having this 2nd GitLab account, I simply upload the ssh key to the account1 without needing set This. But now by following this, still, in the end I could push to the git@gitlab.com:{account_2}/repo1.git. And I'm using TortoiseGit to push/pull.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...