Issue
I have installed git 2.7 on my centos server. and created repository at /srv/repo.git. i am able to clone this using the command
ssh://user@serverIP:/srv/repo.git
.I have installed jenkins & git on my local machine on Windows 10.
Problem: Facing error while setup git repo with jenkins.Please see the screen-shot.
Error:
Failed to connect to repository : Command "git.exe ls-remote -h -- ssh://username@server_ip:/srv/repo.git HEAD" returned status code 128:
stdout:
stderr: ssh: Could not resolve hostname server_ip: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Please help me on this. Thanks in advance.
Solution
I find out the solution of this issue..there was an issue of authentication of jenkins with git server. Just resolve using below steps:
- Open git bash on local machine and generate public/private keyes using command: ssh-keygen
- Copy the id_rsa.pub content to C:\Users\your_windows_user_name here.ssh\known_hosts
- In jenkins got to Source Code Management->Git->Credentials add
- In Jenkins select Kind->SSH Username with private key, Enter directly -> Paste the private generated private key here from the file
- on Linux Server go to .ssh/authorized_keys and paste the C:\Users\your_windows_user_name here.ssh\id_rsa.pub file content here
- In jenkins project configuration go to the "Source code management" section and choose git->Repositary url-> paste this ssh://user@serverIP:/srv/repo.git
- Select the Credentials which we create in step no. 3 & 4.
Answered By - Dinesh Chandra
Answer Checked By - David Goodson (JavaFixing Volunteer)