Skip to content
Advertisement

Git clone with authentication over HTTP protocol

I have a centos 7 server with a git repo shared over smart http, when I make “git push” the authentication works but when I make “git clone” not works. I want than Git and Apache ask me user and password to clone the repos.

/var/www/git -> Is my repo dir /var/www/html -> Is the web sites dir

My site.conf is:

JavaScript

Advertisement

Answer

Your configuration uses a Require expr that matches on git-receive-pack. That’s the service that’s used when you push to the server. In order to make the server require authentication for clones and fetches, you need to match on git-upload-pack as well.

The easiest way to fix this is probably to remove that Require expr line, since it sounds like you want the server to always apply authentication, regardless of the task you’re performing. Removing the Require expr lines removes the exemption for non-push operations.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement