0
votes

While trying to execute some shell command to a remote server from Jenkins, I am getting "Host key verification failed." error.

I have installed Jenkins in a docker on my MAC. Now from the Jenkins browser, I want to run some shell command to a remote server (which is accessible). To do that I already added the server (10.206.y.z) in the configure page of jenkins (by providing hostname i.e. 10.206.y.z, username & the key generated in 10.206.y.z server in the SSH Servers section) & tested the connection. The connection test passed & then I saved the configuration.

For executing shell command on 10.206.y.z, I created a FreeStyle project & in the Execute Shell section I am passing ssh [email protected] 'hostname'. If I run the project by clicking 'Build Now', I am getting the below error & the build fails.

Running as SYSTEM Building in workspace /var/jenkins_home/workspace/TestProject [TestProject] $ /bin/sh -xe /tmp/jenkins4234161871485451783.sh + ssh [email protected] hostname Host key verification failed. Build step 'Execute shell' marked build as failure Finished: FAILURE

Any help please?

1

1 Answers

1
votes

I think that the problem is the key. You are using the key generated in the destination machine (10.206.y.z)

You should use the key generated on the jenkins server and pass it to the destination server. For that you could use ssh-copy-id