title: Permission denied (public key) during fetch from GitHub with Jenkins user on Ubuntu
body: <p>Here is my setup:</p>
  
  <ol>
  <li>Jenkins is running on my linux machine as 'jenkins' user.</li>
  <li>I have generated a ssh key-pair as described in <a href="http://help.github.com/linux-set-up-git/" rel="noreferrer">Linux - Setup Git</a>, for the 'jenkins' user.</li>
  <li>When I <code>sudo su jenkins</code> and try <code>ssh -vT git@github.com</code>, I am always asked my passphrase, but I am always eventually authenicated. (the verbose option shows which key is used, among others).</li>
  <li>I could clone my repo from GitHub using jenkins:</li>
  </ol>
  
  <p>Thusly:</p>
  
  <pre><code>jenkins@alpm:~/jobs/test git/workspace$ git pull 
  Enter passphrase for key '/var/lib/jenkins/.ssh/id*_rsa':
  Already up-to-date.
  </code></pre>
  
  <p>Up to this point I have followed the instructions to the letter. The problem is that the Jenkins job fails with the following error:</p>
  
  <pre><code>status code 128:
  stdout: 
  stderr: Permission denied (publickey).
  fatal: The remote end hung up unexpectedly
  </code></pre>
  
  <p>This is same error as I get when I typo the passphrase (but of course, Jenkins does not ask me for the passphrase). The following pages:</p>
  
  <ul>
  <li><a href="http://help.github.com/ssh-issues/" rel="noreferrer">GitHub - SSH Issues</a></li>
  <li><a href="https://helpnext.github.com/articles/using-ssh-agent-forwarding" rel="noreferrer">Using SSH Agent Forwarding</a></li>
  </ul>
  
  <p>indicate to me that ssh-agent could help remember the passphrase, which it does when I am using my own user, but not the <em>jenkins</em> id. Note that while running as my normal user yields:</p>
  
  <pre><code>echo "$SSH_AUTH_SOCK"
  /tmp/keyring-nQlwf9/ssh
  </code></pre>
  
  <p>While running the same command as my 'jenkins' yields nothing (not even permission denied)</p>
  
  <p><strong>My understanding of the problem is that the passphrase is not remembered.
  Do you have any idea? 
  Shall I start a ssh-agent or key ring manager for the jenkins user? How?
  Or is ssh forwarding suitable when forwarding to the same machine?
  Any brighter idea?</strong></p>
  
  <p>ps: I never <code>sudo gitted</code>, I always used jenkins or my user account (as mentioned in this SO post - <a href="https://stackoverflow.com/questions/4637908/ubuntu-github-ssh-keys-issue">Ubuntu/GitHub SSH Key Issue</a>)</p>