title: git using authorized_keys as authentication
body: <p>I followed <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server" rel="nofollow noreferrer">the official tutorial</a> in order to setup a git server for the first time. When I executed the following:</p>
  
  <pre><code>$ git remote add origin git@gitserver:/opt/git/project.git
  $ git push origin master
  </code></pre>
  
  <p>I was asked for the password of <code>git@gitserver</code>, which I thought was weird, but entered it anyway.</p>
  
  <p>Then when I tried to clone the repository by doing this:</p>
  
  <pre><code>$ git clone git@gitserver:/opt/git/project.git
  </code></pre>
  
  <p>or push to it using this:</p>
  
  <pre><code>$ git push origin master
  </code></pre>
  
  <p>I was asked for the password for <code>git@gitserver</code> every time. I checked and <code>authorized_users</code> contains the public key of the user that's trying to push or clone. Also, I tried what is suggested answer to <a href="https://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use">this question</a>, but that didn't help.</p>
  
  <p>How can I set the server and the client so that I am not asked for a password every time I commit?</p>
  
  <h3>UPDATE</h3>
  
  <p>Output of <code>ssh -v -i ~/.ssh/id_rsa git@gitserver</code>:</p>
  
  <pre><code>OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
  debug1: Reading configuration data /etc/ssh/ssh_config
  debug1: /etc/ssh/ssh_config line 19: Applying options for *
  debug1: Connecting to gitserver [XXX_REDACTED_gitserver_IP] port 22.
  debug1: Connection established.
  debug1: identity file /home/XXX/.ssh/id_rsa type 1
  debug1: identity file /home/XXX/.ssh/id_rsa-cert type -1
  debug1: Enabling compatibility mode for protocol 2.0
  debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
  debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
  debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 pat OpenSSH_6.6.1* compat 0x04000000
  debug1: SSH2_MSG_KEXINIT sent
  debug1: SSH2_MSG_KEXINIT received
  debug1: kex: server-&gt;client aes128-ctr hmac-md5-etm@openssh.com none
  debug1: kex: client-&gt;server aes128-ctr hmac-md5-etm@openssh.com none
  debug1: sending SSH2_MSG_KEX_ECDH_INIT
  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
  debug1: Server host key: ECDSA XXX_REDACTED_PUBLIC_KEY_XXX
  debug1: Host 'gitserver' is known and matches the ECDSA host key.
  debug1: Found key in /home/XXX/.ssh/known_hosts:12
  debug1: ssh_ecdsa_verify: signature correct
  debug1: SSH2_MSG_NEWKEYS sent
  debug1: expecting SSH2_MSG_NEWKEYS
  debug1: SSH2_MSG_NEWKEYS received
  debug1: SSH2_MSG_SERVICE_REQUEST sent
  debug1: SSH2_MSG_SERVICE_ACCEPT received
  debug1: Authentications that can continue: publickey,password
  debug1: Next authentication method: publickey
  debug1: Offering RSA public key: /home/XXX/.ssh/id_rsa
  debug1: Authentications that can continue: publickey,password
  debug1: Next authentication method: password
  debug1: Authentications that can continue: publickey,password
  git@gitserver's password:
  </code></pre>