Fingerprint has already been taken gitlab

Gitlab can use your ssh-key in another account of your past projects for somehow - so, easiest way to solve this problem is to create new ssh-pair, add it to ssh-agent and add id_rsa2.pub to your gitlab account.

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

When it ask:

Generating public/private rsa key pair. 
Enter file in which to save the key (/home/<NAME>/.ssh/id_rsa):  

Please enter /home/<NAME>/.ssh/id_rsa2

$ ssh-add ~/.ssh/id_rsa2

Make sure to cut away everything at the end of the base64 encoded string. Also remove all newlines so the string contains no newlines.

This did the trick for me.


In my case; the public key i was trying to add was already used with 'work' Gitlab account and i received the said error upon trying to use the same key with 'personal' Gitlab account.

Solution - Add another public key on the same machine and use that with 'personal' gitlab account (both on same machine).

navigate to .ssh folder in your profile (even works on windows) and run command

ssh-keygen -t rsa

when asked for file name give another filename id_rsa_2 (or any other). enter for no passphrase (or otherwise). You will end up making id_rsa_2 and id_rsa_2.pub

use the command

cat id_rsa_2.pub

copy and save key in 'personal' Gitlab account.

create a file with no extension in .ssh folder named 'config'

put this block of configuration in your config file

Host           gitlab.com
HostName       gitlab.com
IdentityFile   C:\Users\<user name>\.ssh\id_rsa
User           <user name>


Host           gitlab_2
HostName       gitlab.com
IdentityFile   C:\Users\<user name>\.ssh\id_rsa_2
User           <user name>

now whenever you want to use 'personal' gitlab account simply change alias in git URLs for action to remote servers.

for example instead of using

git clone git@gitlab.com:..............

simply use

git clone git@gitlab_2:...............

doing that would use the second configuration with gitlab.com (from 'config' file) and will use the new id_rsa_2 key pair for authentication.

Find more about above commands on this link
https://clubmate.fi/how-to-setup-and-manage-multiple-ssh-keys/