Local Jenkins can't authenticate remote Gitlab private repository
Solution 1
My Fix :
- Go to jenkins path and save .ssh folder in root example C:\Jenkins.ssh .ssh folder u can find in C:\Users\yourname.ssh
- Go to Jenkins > Manage Jenkins > Manage Credentials, here you can add your private key or select from the jenkins master !/.ssh
- Go to Jenkins > Manage Jenkins > Configure System in git executable wrote this C:\Program Files (x86)\Git\cmd\git.exe path must be with cmd
- Create new job and in repository url add ssh://[email protected]:/name/projet.git
Solution 2
I have folder with .ssh with all keys
Those keys won't never been read, if you keep using an http(s) url.
You should use an ssh url, and first make sure that this works properly:
ssh -Tv ssh://git@git.*****.org
(assuming the user account you need on the server side is 'git
')
Note that the section on SSH of this guide is of interest here:
you have installed TortoiseGIT
If you have ever installed TortoiseGit on the computer you’re setting up your keys on, you may encounter problems.
TortiseGit creates an environment variable that configures Plink as your SSH keystore, which may conflict when you try to use Git and SSH.
No matter how you change your config or uninstall TortoiseGit, that environment variable persists and until you delete it, Git will not look to your regular.ssh
directory to find the proper key.In our case environment variable looked like this:
GIT_SSH=c:\Program Files\Putty\plink.exe.
Environment variables can be found here:
- Windows XP:
Control Panel → System Properties → Advanced → Environment variables
- Windows 7:
Control Panel → System → Advanced system settings → Environment variables
Solution 3
Try using C:\Program Files (x86)\Git\cmd\gitk.cmd
instead of \bin\git.exe
. If not solved, then Here is information how to configure ssh. Sometimes you may also get public key error, which is solved here. If you want to generate new ssh keys, this article will help you.
Andrian Durlestean
Knowing: .net java python selenium sql javascript jquery
Updated on June 19, 2022Comments
-
Andrian Durlestean almost 2 years
I installed Jenkins on windows with all addons that I need, I think so. When i create a new job and in Repository URL i write my url
http://git.*****.org/*****/seleniumproject.git
and it shows
Help for feature: Repository URL Failed to connect to repository : Command "C:\Program Files (x86)\Git\bin\git.exe ls-remote -h http://git.*****.org/*****/seleniumproject.git HEAD" returned status code 128: stdout: stderr: fatal: Authentication failed for 'http://git.*****.org/*****/seleniumproject.git'`
My question: how can I authenticate to my remote gitlab?! I have folder with .ssh with all keys but don't know what to do...
Update: strange because my TortoiseGit is working perfectly
My Fix :
- Go to jenkins path and save .ssh folder in root example
C:\Jenkins\.ssh
.ssh folder u can find inC:\Users\yourname\.ssh
- Go to Jenkins > Manage Jenkins > Manage Credentials, here you can add your private key or select from the jenkins master !/.ssh
- Go to Jenkins > Manage Jenkins > Configure System in git executable wrote this
C:\Program Files (x86)\Git\cmd\git.exe
path must be with cmd - Create new job and in repository url add
ssh://[email protected]:/name/projet.git
- Go to jenkins path and save .ssh folder in root example
-
Andrian Durlestean over 10 yearsJenkins is sending url always with C:\Program Files (x86)\Git\bin\git.exe ls-remote so i can't use -Tv because of this ls-remote
-
VonC over 10 years@AndrianDurlestean the
-Tv
is just for you to test ssh with the ssh-Tv
. But once this is working, you don't need-Tv
in yourls-remote
. -
Andrian Durlestean over 10 yearsi get: no address associated with name
-
Andrian Durlestean over 10 yearsssh://git@git.****.org:9999/ my connection is with port =( i saw in my tortoisegit
-
VonC over 10 yearsCan you try:
ssh -Tv git@git.****.org:9999
(nossh://
and no final/
)? -
Andrian Durlestean over 10 yearssad same problem =(, if Im trying with no port i get msg port 22: Bad file number, but my git server is with port 9999
-
VonC over 10 years@AndrianDurlestean I have edited my answer to address git in an environment where TortoiseGit was already there.
-
VonC over 10 yearsExcellent feedback. +1. More accurate than my answer
-
while1pass almost 7 yearsHello, I have 2 questions. What is
C:\Jenkins
? Home dir for Jenkins? What do you mean inC:\Program Files (x86)\Git\cmd\git.exe path must be with cmd
? Where can I set it?