title: Why does ssh-agent need root access?
body: <p>I've just installed Archbang, and am trying to clone a Git project of mine, which necessitates SSH keys.</p>
  
  <p>I've followed the Github guide to success in the past, on Ubuntu and RedHat boxes, but for some reason it's not working out for me on my new Arch install.</p>
  
  <p>I've successfully generated my SSH public/private key pairs with this command:</p>
  
  <pre><code>ssh-keygen -t rsa -b 4096 -C "email@address"
  </code></pre>
  
  <p>But when I move on to starting up the SSH agent and adding my public key, I run into issues.</p>
  
  <pre><code>[user@arch ~]$ eval "$(ssh-agent -s)"
  bind: Permission denied
  unix_listener: cannot bind to path: /tmp/ssh-ZqYqSabxjZeA/agent.9328
  </code></pre>
  
  <p>This is successful, however, if I run it as root:</p>
  
  <pre><code>[user@arch ~]$ eval "$(sudo ssh-agent -s)"
  [sudo] password for user: 
  Agent pid 9146
  </code></pre>
  
  <p>But I'm pretty sure I don't want to be doing SSH things as root.</p>
  
  <p>Continuing forward, when I then try to use <code>ssh-add</code>, I get permissions errors, as well, but this time as both the standard user and root:</p>
  
  <pre><code>[user@arch ~]$ ssh-add .ssh/id_rsa.pub
  Could not open a connection to your authentication agent.
  [user@arch ~]$ sudo ssh-add .ssh/id_rsa.pub
  Could not open a connection to your authentication agent.
  </code></pre>
  
  <p>So now I'm really confused.</p>
  
  <p>I've tried opening up a bash process as root to do this stuff, but 1) I don't like that idea and 2) it still doesn't work, but this time for a different reason:</p>
  
  <pre><code>[user@arch ~]$ sudo ssh-agent -s
  [root@arch ~]# ssh-add .ssh/id_rsa.pub
  Enter passphrase for .ssh/id_rsa.pub:
  Bad passphrase, try again for .ssh/id_rsa.pub:
  </code></pre>
  
  <p>For some reason, doing this in a root shell causes my SSH key passphrase to be rejected; I've tried this multiple times, with the simplest of passphrases, so I'm positive I've given it the correct passphrase.</p>
  
  <p>I'm at a loss. I really don't like all this <code>sudo</code> stuff, and I don't know why it seems to be necessary; I've checked the permissions on the .ssh directory and its files, even going as far as deleting the whole directory and regenerating the keys to be sure they aren't being generated with the wrong permissions.</p>
  
  <p>Can someone please help me out here? What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong> In response to suggested answers, I have tried this again using a socket location inside my home directory. These are the results:</p>
  
  <pre><code>[user@arch ~]$ mkdir -m 700 ~/.ssh
  [user@arch ~]$ ssh-keygen -t rsa -b 4096 -C "email@address"
  Generating public/private rsa key pair.
  Enter file in which to save the key (/home/user/.ssh/id_rsa): 
  Enter passphrase (empty for no passphrase): 
  Enter same passphrase again: 
  Your identification has been saved in /home/user/.ssh/id_rsa.
  Your public key has been saved in /home/user/.ssh/id_rsa.pub.
  ...
  [user@arch ~]$ chmod 644 .ssh/id_rsa.pub &amp;&amp; chmod 600 .ssh/id_rsa
  [user@arch ~]$ eval "$(ssh-agent -sa .ssh-agent.$$)"
  Agent pid 1881
  [user@arch ~]$ ssh-add .ssh/id_rsa.pub
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  Permissions 0644 for '.ssh/id_rsa.pub' are too open.
  It is recommended that your private key files are NOT accessible by others.
  This private key will be ignored.
  </code></pre>
  
  <p>At this point, I'm confused as to why those permissions are not acceptable, and as to why it thinks my public key is a private key. But I humor it, changing the permissions to 600 and trying to add it again.</p>
  
  <pre><code>[user@arch ~]$ chmod 600 .ssh/id_rsa.pub
  [user@arch ~]$ ssh-add .ssh/id_rsa.pub
  Enter passphrase for .ssh/id_rsa.pub:
  Bad passphrase, try again for .ssh/id_rsa.pub:
  </code></pre>
  
  <p>And now I've gotten to a similar spot as I was before: it does not like the passphrase I've created for my SSH key. What's going on?! This is truly perplexing.</p>