0

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:

  1. on workstation [WS] I (or any of my colleague) push to bare repo on central server [CENTRAL]
  2. there is triggered post-update hook [CENTRAL] which should do git push to 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
Foton
  • 1,197
  • 13
  • 24
  • `Defaults:your_user !requiretty` in `/etc/sudoers` should help you – Jakuje Sep 15 '15 at 09:59
  • Unfortunatelly not. Tried: `Defaults:lamparna !requiretty` and `Defaults !requiretty` – Foton Sep 16 '15 at 07:01
  • 1
    I found answer in 'duplicated' question: I have to use `sudo -u lamparna /usr/bin/git push --mirror ssh://lamparna@REDMINE/home/lamparna/repos/git/jine/lamparna.git` to work without password. Difference is `git push` vs `/usr/bin/git push` . – Foton Sep 16 '15 at 07:20

0 Answers0