title: ssh-add from bash script and automate passphrase entry
body: <p>I am trying to do ssh-add from script (don't care about about security at the moment).</p>
  
  <p>Now ssh prompts for passphrase, which needs to be automated, so i read couple of things like <a href="https://unix.stackexchange.com/questions/90853/how-can-i-run-ssh-add-automatically-without-password-prompt">this</a> and found <a href="http://expect.sourceforge.net/" rel="noreferrer">expect</a>.</p>
  
  <p>And now i do following:</p>
  
  <pre><code>eval `ssh-agent -s`
  </code></pre>
  
  <p>script tmp.sh defined as : </p>
  
  <pre><code>#!/usr/bin/expect
  spawn ssh-add /root/.ssh/id_rsa
  expect "Enter passphrase for /root/.ssh/id_rsa:"
  send "my_pass"
  interact
  </code></pre>
  
  <p><code>./tmp.sh</code></p>
  
  <p><code>ssh-add -l</code></p>
  
  <p>If ssh-add would have worked it shows something like </p>
  
  <p><code>4096 SHA256:wlfP/nhVSWXLcljBOen5GSYZXJGgfi/XJWfZeBwqRsM id_rsa (RSA)</code></p>
  
  <p>But instead i get <code>The agent has no identities.</code> Seems like ssh-agent looses it's context.</p>
  
  <p>Am open to other solutions to do this.</p>