<p>I have create cron job in kubernetes and I have ssh key in one of  pod directory. when I am executing from command line its working fine, but when I am manually triggered , cron job is not recognizing .ssh folder .</p>

<pre><code>scp -i  /srv/batch/source/.ssh/id_rsa   user@server:/home/data/openings.csv  /srv/batch/source
</code></pre>

<p><a href="https://i.stack.imgur.com/JxtiG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JxtiG.png" alt="enter image description here"></a></p>

<p>When you log into a remote host from your container, the remote host key is  unknown to your SSH client inside the container</p>

<p>usually, you're asked to confirm its fingerprint:</p>

<pre><code>The authenticity of host ***** can't be established.
RSA key fingerprint is *****.
Are you sure you want to continue connecting (yes/no)?
</code></pre>

<p>But as there is no interactive shell, the SSH client fails.</p>

<p>Two solutions:</p>

<ul>
<li>add the host key in the file <code>~/.ssh/known_hosts</code> in the container</li>
<li><p>disable host key check (<strong>Dangerous as no remote host authentication is performed</strong>)</p>

<p><code>ssh -o "StrictHostKeyChecking=no" user@host</code></p></li>
</ul>
