简体   繁体   中英

gitlab: git clone ssh still prompts for password, ssh -T is working

I am aware of all the questions regarding SSH login to a gitlab instance still prompting for a password, but none of the answers describes what I am experiencing.

Expected behavior: git clone works without prompting for a password, since it uses the stored SSH key to authorize against a running gitlab instance.

Actual behavior: I get a password prompt for user "git" instead of cloning the repo.

I am trying to clone a git repo on windows using Git bash from my own gitlab instance, but I still get prompted for a password despite the fact, that ssh -T git@host:port/path/to/repo.git is working properly.

$ ssh -T git@xxx.xxx.xxx.xxx -p 12345
Welcome to GitLab, @User!

I did the following steps:

  1. create a SSH key pair, upload public key to gitlab
  2. open git bash (windows) and test the SSH connection using ssh -T
  3. try to clone the repo (using the same git bash) with the following command: git clone --progress -v "ssh://git@host:port/path/to/repo.git"

eval 'ssh-agent' returns a PID, I even tried ssh-add to add the SSH identiy again. But since the SSH connection is working properly, the problem seems to be the git clone command which simply ignores my SSH identity. If the gitlab server was the problem, ssh -T should not work, right?

What am I missing here?

Found the solution myself. Had a long forgotten but still active TortoiseGit installation from medieval times. That was messing with the $GIT_SSH environment variable, leading to the use of TortoisePlink and thus ignoring my local .ssh config for git bash.

After removing TortoiseGit everything is working as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM