Ssh – How to prevent ssh git push to set file ownership

gitpermissionsssh

I have a remote bare Git repository on an Ubuntu server, where the files are owned by the user my_project and the group my_project, with permissions set accordingly. All commiters are themself in the group my_project.

When somebody commit then push from any Ubuntu laptop with the user my_user to the server via SSH, some files in the remote repository are created (updated?) so they now belong to the user and group my_user.

Of course, when somebody else wants to commit, he is now unable to do so because he doesn't have write permissions. I could set permission to 777 but it's not the best option.

Is there any way I can solve this problem while keeping restricted write permissions?

Best Answer

Would the SUID and SGID bits help you? I use a similar mechanism to allow members of the bzr group to commit files to a bazaar central repo and still keep the accessible permissions.

drwsrwsr-x  3 bzr          bzr          4.0K 2010-04-15 17:58 bzr

set with sudo chmod ug+s /home/bzr

/etc/group contains bzr:x:1012:bzr,tom,<and a whole bunch of other usernames>

This seems to work pretty well for us, allowing users in the bzr group to commit files to the central repository.

Setting mode 777 probably isn't ideal, for the obvious security reasons.

If I've missed the point, oops.