Managing SSH keys within Jenkins for Git

0 votes

I'm trying to get Jenkins up and running with a GitHub hosted repository. I'm not sure I have to try and manage multiple deploy keys because The repository has multiple git submodules.

My personal GitHub user account is a collaborator of each of the projects I wish to pull in with Jenkins, so I've generated an SSH key within /var/lib/jenkins/.ssh and added it to my personal GitHub account.

However, when I try and add the repository URL to my Jenkins project configuration, I get:

Failed to connect to repository : Command "git ls-remote -h***/***.git HEAD" returned status code 128:
stderr: Host key verification failed. 
fatal: The remote end hung up unexpectedly

Where am I going wrong?

Aug 9, 2018 in Jenkins by lina
• 8,100 points

1 answer to this question.

0 votes

The host which Jenkins tries to connect to is not listed under the Jenkins user's $HOME/.ssh/known_hosts. Jenkins has its own ssh directory to store the list of public keys and known hosts.

The easiest thing to do would be:

# Login as the jenkins user and specify shell explicity,
# since the default shell is /bin/false for most
# jenkins installations.
sudo su jenkins -s /bin/bash
# git clone YOUR_GITHUB_URL
# Allow adding the SSH host key to your known_hosts
# Exit from su
answered Aug 9, 2018 by Kalgi
• 37,320 points

Related Questions In Jenkins

0 votes
1 answer

Why is it displaying Jenkins build failure for Android app

I think you should try this. Try Uninstalling ...READ MORE

answered Apr 12, 2018 in Jenkins by shubham
• 6,870 points
0 votes
2 answers

Is possible for Jenkins to auto start and stop slave nodes?

Try Jenkins Plugin called as Slave SetupPlugin. This ...READ MORE

answered Aug 6, 2018 in Jenkins by Nilesh
• 6,900 points
0 votes
1 answer

Ansible or Jenkins pipelines for bigger jobs

Well, you are indeed well aware of ...READ MORE

answered Jun 16, 2018 in Jenkins by shubham
• 6,870 points
0 votes
1 answer

Unable to access Jenkins. I newly installed Jenkins but for some reason I cannot access it.

Try changing the port, Change JENKINS_AJP_PORT="xyz" to JENKINS_AJP_PORT="abc" If changing the ...READ MORE

answered Jul 4, 2018 in Jenkins by Sophie may
• 9,430 points
+13 votes
2 answers
0 votes
1 answer
+1 vote
3 answers
0 votes
2 answers

Jenkins Git plugin detached HEAD

Go to Job Configuration. Scroll down to ...READ MORE

answered Aug 13, 2018 in Jenkins by lina
• 8,100 points