问题
I have a git repo on my server that I can push/pull through SSH just fine like:
git clone ssh://user@domain.com/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!
回答1:
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
.
回答2:
You could use git-daemon. That will remove the dependency on having valid ssh credentials.
回答3:
You can use git-shell, set only read permissions on the repository, and use key authentication. This is feasible when you are in control of who gets the key.
来源:https://stackoverflow.com/questions/9620584/how-can-i-set-read-only-access-to-ssh-git-server