Given that:
git clone ssh://remote/src/proj1
and subsequent git pull
/ git fetch
execute git-upload-pack 'src/proj1'
(with the quotes)
git push
etc executes git-receive-pack 'src/proj1'
on the remote server
in your ~/.ssh/authorized_keys
you can setup a line beginning with:
command="/home/yourusername/bin/checker" ssh-…
where the … part is the public key of the private SSH key you will give your users.
The /home/yourusername/bin/checker
can be a shell script along the lines:
case $SSH_ORIGINAL_COMMAND in
(git-upload-pack*)
# run git-upload-pack after unquoting its argument, optionally further restricting
# access to specific directories
;;
(git-receive-pack*)
exit 1 # deny access
;;
(*)
exit 1 # allow nothing else
;;
esac
Please check the authorized_keys man page for extra security options like no-port-forwarding
which most probably you want to include along the command="…"
option in your authorized_keys
file.