Linux: Allow git repo push over ssh without allowing shell access

If you have a git repo on a server and allow users to push over ssh using their public keys, then you might want to add this to every entry on the authorized_keys file on .ssh

For each ssh pub key on authorized_keys pre-append this

command="./.gitserve",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty

Where .gitserve is a script allowing only git commands to be executed

#!/bin/bash

exec git-shell -c "$SSH_ORIGINAL_COMMAND"