Search code examples
gitsshrepositorysharedgit-clone

How can I set read only access to ssh git server?


I have a git repo on my server that I can push/pull through SSH just fine like:

git clone ssh://[email protected]/repositories/myrepo.git

It prompts me with my public key passcode and I'm able to fetch or push changes to it, but I was wondering if there was a way where I could set it up so people can clone it only with read access so they don't have to enter any SSH credentials.

Thanks in advance!


Solution

  • Not through ssh; unless you wanted to distribute a public is they could log in with, and that is a terrible idea.

    The way we got this functionality on our gitolite was to use git-daemon; you need to open a new port, but can specify per-repository which ones it will serve, and can specify read-only. Users would clone with the git protocol i.e.

    git clone git://domain.com/repositories/myrepo.git

    Another way is to set the repository to be shared over a web server directly; then the user could access over standard http.

    The page on the git community book here is a good overview, along with the man pages for git-daemon.