Deploying from Jenkins server to another server: Host key verification failed
<p>I am trying to deploy to another server from Jenkins server, and I can't do it using Jenkins Build script.</p>

<p>When I am on the Jenkins server, I can deploy. For example:</p>

<pre><code>:/var/lib/jenkins/workspace/MyProject$ scp my_file ubuntu@my_address:~/MyProject
</code></pre>

<p>Runs perfectly fine; however,</p>

<p>When I specify:</p>

<pre><code>scp my_file ubuntu@my_address:~/MyProject
</code></pre>

<p>In "Execute Shell" under build in Jenkins window. I get the following error:</p>

<pre><code>Host key verification failed.
</code></pre>

<p>I know that the first time I ran the above command directly on Jenkins server, I was prompted:</p>

<pre><code>The authenticity of host 'my_address (my_address)' can't be established.
ECDSA key fingerprint is cf:4b:58:66:d6:d6:87:35:76:1c:aa:cf:9a:7c:78:cc.
Are you sure you want to continue connecting (yes/no)?
</code></pre>

<p>So I had to hit "yes" in order to continue. But since I already directly in the terminal, I don't have to do anything extra.</p>

<p>Second answer to this question: <a href="https://stackoverflow.com/questions/15174194/jenkins-host-key-verification-failed">Jenkins Host key verification failed</a></p>

<p>indicates that, if I understand it correctly.</p>

<p>What am I missing? What can I do to fix my problem?</p>