Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins, Host key verification failed, script returned exit code 255

I have a building-server where I have Jenkins 2.73.3 and another servers where I deploy my apps.

I have also set up a credential to connect from building-server to the other servers.

But everytime I add another server it is difficult to add it because I set up the authorized key in the new server and in the command line works, but not in Jenkins.

Here is a little recipe that fails:

pipeline {
  agent any

  stages {

    stage('Set conditions') {
      steps {
        sshagent(['xxxx-xxxx-xxxx-xxxx-xxxx']) {
          sh "ssh [email protected] 'echo $HOME'"
        }
      }
    }

  }
}

And here is the Log failure:

[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
[check] Running shell script
+ ssh [email protected] echo /var/lib/jenkins
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 12567 killed;
[ssh-agent] Stopped.
Host key verification failed.
[Pipeline] }
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 255
Finished: FAILURE
like image 325
agusgambina Avatar asked Oct 18 '25 14:10

agusgambina


1 Answers

It seems that the solution was to add the parameter StrictHostKeyChecking to the shell script line

sh "ssh -o StrictHostKeyChecking=no [email protected] 'echo $HOME'"
like image 143
agusgambina Avatar answered Oct 21 '25 13:10

agusgambina