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