jenkins credentials not used as expected when cloning git repo I am trying to setup a jenkins pipeline for my IaC code validation, for this I'd like jenkins to clone a gitlab (hosted) repository, for this purpose I setup a credential using username / key type, i used a jenkins user + a generated rsa key (same key on master and slave for simplicity).

When logged in the master or slave I can git clone using the following command and result :

root@jenkins-slave-1 [~]: su - jenkins
jenkins@jenkins-slave-1:~$ cd /tmp/
jenkins@jenkins-slave-1:/tmp$ git clone git@l-gitlab1.domain:salt/salt_states.git
Cloning into 'salt_states'...
remote: Enumerating objects: 1177, done.
remote: Counting objects: 100% (1177/1177), done.
remote: Compressing objects: 100% (483/483), done.
remote: Total 1177 (delta 676), reused 1153 (delta 665)
Receiving objects: 100% (1177/1177), 1.64 MiB | 0 bytes/s, done.
Resolving deltas: 100% (676/676), done.
jenkins@jenkins-slave-1:/tmp$ 



I can see the correct entry in auth log on gitlab instance, the one saying that a pubkey authentication was accepted.

BUT, when I run the pipeline (that is using the same credentials), it fails with this message :

Cloning the remote Git repository
Honoring refspec on initial clone
Cloning repository git@l-gitlab1.domain:salt/salt_states.git
 &gt; git init /home/jenkins/workspace/salt_build_test # timeout=10
Fetching upstream changes from git@l-gitlab1.domain:salt/salt_states.git
 &gt; git --version # timeout=10
using GIT_SSH to set credentials jenkins user's key (same key on master and slave(s))
 &gt; git fetch --tags --progress -- git@l-gitlab1.domain:salt/salt_states.git +refs/remotes/origin/dev # timeout=20
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress -- git@l-gitlab1.domain:salt/salt_states.git +refs/remotes/origin/dev" returned status code 128:
stdout: 
stderr: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


The gitlab auth log is showing that the authentication tried to use a password auth mode, not a pubkey. ...

Oct  8 11:49:23 l-gitlab1 sshd[18490]: Failed password for git from 172.27.200.46 port 56750 ssh2
Oct  8 11:49:23 l-gitlab1 sshd[18490]: Connection closed by 172.27.200.46 port 56750 [preauth]


Any ideas about what I am doing wrong ?

The error:


[Edit]
I added a screenshot as my explanation are not very clear :(
The Gitlab plugin requires an auth token, you're trying to use an SSH key.

https://github.com/jenkinsci/gitlab-plugin#global-plugin-configuration

"PLEASE NOTE: This auth configuration is only used for accessing the GitLab API for sending build status to GitLab. It is not used for cloning git repos. The credentials for cloning (usually SSH credentials) should be configured separately, in the git plugin."