threads / discuss / 33538

Git over HTTPS with basic authentication

Subject: Git over HTTPS with basic authentication

## tl;dr

4 messages between Apr 18, 2013 and Apr 19, 2013.

replies: 3people: 3as markdown or json

Sebastian Schmidt· Apr 18, 2013, 19:47 UTC · lore

Why is git not working over HTTPS with basic authentication? I can clone just fine, but when I try to push, it tells me

error: Cannot access URL https://..., return code 22 fatal: git-http-push failed

I have googled for an hour now, all I find is people that have the same problem and the solution is always to use SSH.

Sibbo
Matthieu Moy· Apr 18, 2013, 19:54 UTC · re: Sebastian Schmidt · lore

Re: Git over HTTPS with basic authentication

Sebastian Schmidt <isibboi@gmail.com> writes:
> Why is git not working over HTTPS with basic authentication? I can clone
> just fine, but when I try to push, it tells me

What are you using on the server? Dumb HTTP works by serving the repository files as static pages, which is fundamentally read-only. The recommended way is to use smart-HTTP (see man git-http-backend, requires Git on the server), and the alternative is to use webdav (much slower).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Jeff King· Apr 18, 2013, 20:43 UTC · re: Matthieu Moy · lore

Re: Git over HTTPS with basic authentication

On Thu, Apr 18, 2013 at 09:54:32PM +0200, Matthieu Moy wrote:
Show 9 quoted lines
> Sebastian Schmidt <isibboi@gmail.com> writes:
> 
> > Why is git not working over HTTPS with basic authentication? I can clone
> > just fine, but when I try to push, it tells me
> 
> What are you using on the server? Dumb HTTP works by serving the
> repository files as static pages, which is fundamentally read-only. The
> recommended way is to use smart-HTTP (see man git-http-backend, requires
> Git on the server), and the alternative is to use webdav (much slower).

Yeah, this is definitely dumb http (since http-push is involved at all, which the original error message showed). Code 22 is curl's "there was an HTTP error" code, but http-push annoyingly does not output the actual HTTP error[1]. You can see more by setting GIT_CURL_VERBOSE=1 in the environment.

Though if you know you did not set up WebDAV on the server, then we can know that is the problem even without seeing the HTTP code. :)

-Peff
[1] The dumb-http push code is largely unloved and unmaintained at this
    point. Yet another reason to move to smart http.
Jeff King· Apr 19, 2013, 15:36 UTC · lore

Re: Git over HTTPS with basic authentication

On Fri, Apr 19, 2013 at 10:56:06AM +0200, Sebastian Schmidt wrote:
Show 7 quoted lines
> I tried switching to smart http now, but have the same error, I guess I
> did something wrong. It seems like it is getting 401, but I also noticed
> that info/refs is just an empty file. This is the config of my apache2:
> 
> SetEnv GIT_PROJECT_ROOT /crypt/git
> SetEnv GIT_HTTP_EXPORT_ALL
> ScriptAlias /git/ /usr/lib/git

This should point to /usr/lib/git/git-http-backend, which I think is the source of your problems.

Show 11 quoted lines
> <Directory /crypt/git>
> 	Allow from all
> 	Order deny,allow
> 	
> 	AuthType Basic
> 	AuthName "Git global"
> 	AuthUserFile /etc/apache2/auth/passwd
> 	AuthGroupFile /etc/apache2/auth/groups
> 	
> 	Require group git-shared
> </Directory>

I'm not sure this <Directory> match will do what you want, because from Apache's perspective, it is hitting /usr/lib/git/git-http-backend on the filesystem, and it is only git that actually touches the filesystem.

I think you want to use
  <Location /git>
     ...
  </Location>
instead. But I am not an Apache expert, so maybe it does work.
-Peff

← back to recent threads