Search code examples
gitgitosissvn

git-shell equivalent of svnserve -r?


I'm trying set up a git repository on a shared hosting account that can be accessed by both me and a friend. I have successfully done this with a Subversion repository by adding this line to ~/.ssh/authorized_keys:

command="/usr/bin/svnserve -t -r /path/to/svn/repo \
  --tunnel-user=myfriend",no-port-forwarding,no-agent-forwarding,\
  no-X11-forwarding,no-pty [ssh key]

I have got so far as to learn that git-shell is git's equivalent of svnserve, but there doesn't seem to be an equivalent of the -r option to restrict access to particular path. This is problematic because there are other git repositories that I don't want my friend to have access to.

I've read briefly about gitosis, which seems to be able to do what I'm wanting, but I want to see if there's a simpler solution before trying to set up another piece of software to accomplish this one specific requirement. Thanks in advance!

Edit: I found this article that provides a script to do it:

http://eagain.net/blog/2007/03/22/howto-host-git.html

But in fact, it's written by the same guy that later wrote gitosis and is marked as obsolete. It also seems that gitosis won't be possible in my situation because it requires creating a dedicated UNIX user which I can't do with a shared hosting account. I'd love to be proven wrong if I've misunderstood any of this, however!


Solution

  • Here are some options:

    • Control which repositories a user can access using normal Unix permissions.

    • Use a restricted login shell such as rssh and have your friend use rsync:// URLs for his remotes.

    • Serve the repository over HTTP or HTTPS with a username and password to protect it. You'll want to enable the git hook for updating the metadata.