title: How do I use SSH in a Jenkins pipeline?
body: <p>I have some Jenkins jobs defined using a Jenkins Pipeline Model Definition, which builds NPM projects. I use Docker containers to build these projects (using a common image with
  just Node.js + npm + yarn).</p>
  
  <p>The results of the builds are contained in the <code>dist/</code> folder that I zipped using a <code>zip</code> pipeline command.</p>
  
  <p>I want to copy this ZIP file to another server using SSH/SCP (with private key authentication). My private key is added to the Jenkins environment (credentials manager), but when I use Docker containers, an SSH connection cannot be established.</p>
  
  <p>I tried to add <code>agent { label 'master' }</code> to use the master Jenkins node for file transfer, but it seems to create a clean workspace with new Git fetch, and without my built files.</p>
  
  <p>After I tried the SSH Agent Plugin, I have this output:</p>
  
  <pre><code>Identity added: /srv/jenkins3/workspace/myjob-TFD@tmp/private_key_370451445598243031.key (rsa w/o comment)
  [ssh-agent] Started.
  [myjob-TFD] Running shell script
  + scp -r dist test@myremotehost:/var/www/xxx
  $ docker exec bfda17664965b14281eef8670b34f83e0ff60218b04cfa56ba3c0ab23d94d035 env SSH_AGENT_PID=1424 SSH_AUTH_SOCK=/tmp/ssh-k658r0O76Yqb/agent.1419 ssh-agent -k
  unset SSH_AUTH_SOCK;
  unset SSH_AGENT_PID;
  echo Agent pid 1424 killed;
  [ssh-agent] Stopped.
  Host key verification failed.
  lost connection
  </code></pre>
  
  <p>How do I add a remote host as authorized?</p>