title: Jenkins, Host key verification failed, script returned exit code 255
body: <p>I have a <code>building-server</code> where I have Jenkins 2.73.3 and another servers where I deploy my apps.</p>
  
  <p>I have also set up a credential to connect from <code>building-server</code> to the other servers.</p>
  
  <p>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.</p>
  
  <p>Here is a little recipe that fails:</p>
  
  <pre><code>pipeline {
    agent any
  
    stages {
  
      stage('Set conditions') {
        steps {
          sshagent(['xxxx-xxxx-xxxx-xxxx-xxxx']) {
            sh "ssh user@product.company.com 'echo $HOME'"
          }
        }
      }
  
    }
  }
  </code></pre>
  
  <p>And here is the Log failure:</p>
  
  <pre><code>[ssh-agent] Started.
  [Pipeline] {
  [Pipeline] sh
  [check] Running shell script
  + ssh user@product.company.com 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
  </code></pre>