Ssh – Via ssh, git-checkout into directory the user doesn’t own: “Permission denied”

gitpermissionssshunix

Using git push server I push to a remote bare git-repository via ssh.
The git-repository on the server has a post-receive hook which runs git checkout -f in /var/www/vhosts/domain.com/preview (working tree) for deployment.

I get

error: git checkout-index: unable to create file README (Permission denied)

[etc…]

whenever the hook gets executed.

This makes sense to me, as the ssh-user "bob" does not own the directory "preview", so he has no write permissions.

root@www:~# ls -lh /var/www/vhosts/domain.com/ | grep preview

drwxr-x--- 5 sumo psaserv 4.0K Mar 29 15:38 preview

Should I add "bob" to the "psaserv" group and chmod 775 the directory (which didn't work), or is this the complete wrong direction? Is the only option to connect to the server with "sumo" instead of "bob"?

I read up on unix permissions but still can not really figure out the proper way to solve this. Any pointers are appreciated!

Best Answer

Adding bob to psaserv group and chmod -R g+w /var/www/vhosts/domain.com/ should sort it for you.

Related Topic