title: git push (over ssh) hook on remote repo ask for password even if it should not
body: <p>What I am trying to accomplish is automatic one way synchronization of 2 bare repos on different machines over ssh.</p>
  
  <p>Pushing from one bare repo [CENTRAL machine] to another bare repo on other machine [REDMINE machine] like this:</p>
  
  <ol>
  <li>on workstation [WS] I (or any of my colleague) push to bare repo on central server [CENTRAL] </li>
  <li>there is triggered <em>post-update</em> hook [CENTRAL] which should do <code>git push</code> to another bare repo [REDMINE] under user <code>'lamparna'</code> (which have access to REDMINE with keys)</li>
  </ol>
  
  <p>The complication is, that I push on WS -> CENTRAL as <code>'foton'</code> and hooked push have to be done as <code>'lamparna'</code> (CENTRAL -> REDMINE).</p>
  
  <p>post-update hook [on CENTRAL]:</p>
  
  <pre><code>#!/usr/bin/env ruby
  # post-receive
  `sudo -u lamparna git push --mirror ssh://lamparna@REDMINE/home/lamparna/repos/git/jine/lamparna.git`
  </code></pre>
  
  <p>I already manage it to work on "imitating push" (according to <a href="http://krisjordan.com/essays/setting-up-push-to-deploy-with-git" rel="nofollow">http://krisjordan.com/essays/setting-up-push-to-deploy-with-git</a> ):</p>
  
  <p>on [WS] </p>
  
  <pre><code>ssh CENTRAL  'cd /opt/git_repos/jine/lamparna.git &amp;&amp; echo "$FROM_COMIT_HASH $TO_COMIT_HASH" | /opt/git_repos/jine/lamparna.git/hooks/post-update'
  </code></pre>
  
  <p>This will run correctly, no password needed.
  But when I do a real push: <code>git push</code>, then pushing on CENTRAL is done, hook is triggered, but end with: </p>
  
  <pre><code> remote: sudo: no tty present and no askpass program specified
  </code></pre>
  
  <p>Surrounding:
  On CENTRALL I allowed all users from group <code>sitd</code> to run git as <code>lamparna</code> without password:</p>
  
  <pre><code>%sitd ALL=(lamparna) NOPASSWD: /usr/bin/git_push_to_lamparna.sh, /usr/bin/git
  </code></pre>