Axel AMGHAR
Axel AMGHAR

Reputation: 315

Asking for password when cloning via ssh

Im using a custom installation of gitlab. Im in wsl2

Version of ssh :

ssh -V
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f  31 Mar 2020

I created my ssh key , then add it to gitlab

I also added the key with ssh-add

ssh-add -l
4096 SHA256:XXX...XXX (RSA)

But I have an error when i want to clone a git repo via ssh

git clone [email protected]:user/repo_name.git
[email protected]'s password:
Permission denied, please try again.

But when i do

ssh -T [email protected]
Welcome to GitLab, user

It don't ask me for a password.

Do someone have a solution ? i already searched everywhere but found nothing

Upvotes: 2

Views: 5171

Answers (1)

Axel AMGHAR
Axel AMGHAR

Reputation: 315

My bad, it was an obvious problem that i didn't see. For people who have the same prolem, the folowing solution will propably NOT be for you since is a special case.

Solution: I was loged in with to my server with a simple user

and when i cloned i used sudo so when conecting in ssh, the sytem searched for

root/.ssh/id_rsa

instead of

/home/user/.ssh/id_rsa

Where my ssh key actualy was, So because it can't connect in ssh via the key, the terminal show me a password to enter

The command that help me find this was

sudo GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone [email protected]:my-group/my-project.git

So avoid using sudo with git commands

Upvotes: 6

Related Questions