0
votes

What can I solve this problem?
when I wanted to connect my personal GitLab account, I got an error message like the following picture

### shell script     
git clone [email protected]:<username>/test1.git

enter image description here

GitLab server-side

enter image description here

Clone ssh address

enter image description here

PS: I have checked and found some reference from StackOverflow but unfortunately it isn't okay for me
1.git clone through ssh
2.SSH and Git Clone
3.git clone with ssh issue

2
Did you find your ssh keys (private and public) in your local machine at this location using git-bash ~/.ssh ?Ahmed HENTETI
@A.Henteti yes! thanks for your reminder me, I found a solution to handle this issue , thanks againWillie Cheng
It appears to be due to multiple public keys, one of the other answers in @phd's link: stackoverflow.com/a/21938804/129686Tyler Szabo

2 Answers

2
votes

I have found a great reference but sorry for Mandarin website, however, I can use my way to share how to deal with this issue.

Step 1:

ls -al ~/.ssh

enter image description here

Step 2:

ssh-keygen 

(using enter key for default value) enter image description here Step 3: To setup config file

vim /c/Users/Willie/.ssh/config

Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa

Step 4:

git clone [email protected]:<username>/test2.git

enter image description here

Step 5:
When you finished Step 4
1.the test2.git file will be download done
2.you will get the new file(known_hosts) in the ~/.ssh
enter image description here

PS: I create the id_rsa and id_rsa.ub by myself and I deliver it to the Gitlab server. using both keys to any client-sides(windows and Linux).

0
votes

Check first if you do have a ~/.ssh/id_rsa private key/~/.ssh/id_rsa.pub public key.

If so, check your private key: if it has 70 chars per line, try and regenerate with the old PEM format:

ssh-keygen -m PEM -t rsa -P "" -f ~/.ssh/id_rsa

(That will override your current key, but if said current key is not working anyway, that should be OK).
Update the public key on GitLab side, and try again, with a simple:

ssh -T [email protected]

Using a config file means not using the user and using a shorter name:

Host gitlab
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa 

means: ssh -T gitlab or git clone gitlab:<username>/test2.git will work.