-->

Monday, January 30, 2023

[Solved] Fingerprint sha256 has already been taken

 ISSUE:-

While cloning the repository from the Gitlab the following error occurs


Error:-

The form contains the following error:
Fingerprint sha256 has already been taken

Cause:-

The issue was occuring because i have already added the key of my laptop to the company's gitlab account. And than when i created my own personal gitlab account and tried to clone the repository it complains that the key is already been taken


Solution:-

1. Create a new RSA key file as

ssh-keygen -t rsa

2. Enter the key file as id_rsa2

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ankit.mittal/.ssh/id_rsa): /Users/ankit.mittal/.ssh/id_rsa2
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/ankit.mittal/.ssh/id_rsa2
Your public key has been saved in /Users/ankit.mittal/.ssh/id_rsa2.pub

3. Add the public key i.e. id_rsa2 to the personal gitlab account

4. Add the config file to the .ssh folder in your user home directory as

(base) C02Z52TZLVCG:~ ankit.mittal$ cd .ssh/
(base) C02Z52TZLVCG:.ssh ankit.mittal$ vim config
(base) C02Z52TZLVCG:.ssh ankit.mittal$ cat config 

Host           gitlab.com
HostName       gitlab.com
IdentityFile   ~/.ssh/id_rsa
User           ankit.mittal


Host           gitlab_2
HostName       gitlab.com
IdentityFile   ~/.ssh/id_rsa2
User           ankit.mittal
5. Run the bash command to make sure the new shell reads the updated config file as
bash
6. For your personal gitlab account just replace gitlab.com with gitlab_2 as
bash-3.2$ git clone git@gitlab_2:unixcloudfusion/first-project.git
Cloning into 'first-project'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
7. If you check the remote now it will show you gitlab_2 which will automatically be aliased to hostname gitlab.com behind the scenes by the config file so you can continue working the same way without releasing any changes apart from converting gitlab.com origin to gitlab_2
bash-3.2$ git remote -v
origin  git@gitlab_2:unixcloudfusion/first-project.git (fetch)
origin  git@gitlab_2:unixcloudfusion/first-project.git (push)

0 comments:

Post a Comment