Downloading gerrit project tgz with curl via link provided by gitweb

954 views
Skip to first unread message

Igor

unread,
Jul 25, 2016, 8:18:15 AM7/25/16
to Repo and Gerrit Discussion
Hi,

I'm trying to figure out how I can download tgzipped project from gerrit with link provided by internal gitweb. This works fine from the browser, so seems that access permissions are Ok, however curl does not bring anything. The command I'm trying is:


also tried adding "a" after server url:


Will appreciate any help,
best regards,
Igor.





Saša Živkov

unread,
Jul 25, 2016, 8:55:11 AM7/25/16
to Igor, Repo and Gerrit Discussion
This format should actually work.
You can add the -v (verbose) option to your curl command to see the HTTP response.
If your Gerrit server uses digest (instead of basic) authentication then you will also need to add the --digest option to your curl command.

 

Will appreciate any help,
best regards,
Igor.





--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igor

unread,
Jul 25, 2016, 10:21:29 AM7/25/16
to Repo and Gerrit Discussion
We have LDAP authentication, so I'm using LDAP user and password. Here what I get with verbose option:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to gerrit port 8443 (#0)
*   Trying XX.XX.XX.XX...
* Connected to gerrit (XX.XX.XX.XX) port 8443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_DHE_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
*       subject: CN=*. ...
*       start date: Jun 13 00:00:00 2016 GMT
*       expire date: May 10 23:59:59 2018 GMT
*       common name: *. ...
*       issuer: CN=thawte SHA256 SSL CA,O="thawte, Inc.",C=US
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Server auth using Basic with user 'user'
> GET /gitweb?p=training/course.git;a=snapshot;h=9c1e2f9a8df8fa14e4db148437444ed4de00e2a2;sf=tgz HTTP/1.1
> Authorization: Basic YnVpbGQ6YnVpbGQ=
> User-Agent: curl/7.29.0
> Host: gerrit:8443
> Accept: */*
< HTTP/1.1 302 Found
< Date: Mon, 25 Jul 2016 14:16:50 GMT
< Content-Length: 0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host gerrit left intact

Björn Pedersen

unread,
Jul 25, 2016, 11:06:46 AM7/25/16
to Repo and Gerrit Discussion
The second response is a redirect to the login page, so that explains the download failure. The pasword needed here is not the LDAP
password (I think unless HTTP_LDAP is used as auth method).

I am not sure if it would work with the HTTP password (that needs to be set on the user preferences page).  If I read the
docs correctly, then these will only be used in the git-over-http path. But at least the /a/ is needed to force authenticatio.

Björn

Saša Živkov

unread,
Jul 25, 2016, 5:39:39 PM7/25/16
to Igor, Repo and Gerrit Discussion
On Mon, Jul 25, 2016 at 4:21 PM, Igor <igor.lit...@gmail.com> wrote:
We have LDAP authentication, so I'm using LDAP user and password. Here what I get with verbose option:


In this case you forgot the "/a" prefix to force the authentication.

Q: what is the value of auth.gitBasicAuth in your gerrit.config?
 

Igor

unread,
Jul 26, 2016, 5:06:13 AM7/26/16
to Repo and Gerrit Discussion, igor.lit...@gmail.com
The value of auth.gitBasicAuth is not set, so according to documentation it is false.

I added /a prefix, now I get the "401 Unauthorized" error. Also I created http password and tried with http password as well, but the result is the same:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to gerrit port 8443 (#0)
*   Trying XX.XX.XX.XX...
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to gerrit (XX.XX.XX.XX) port 8443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_DHE_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
*       subject: CN=*. ...
*       start date: Jun 13 00:00:00 2016 GMT
*       expire date: May 10 23:59:59 2018 GMT
*       common name: *. ...
*       issuer: CN=thawte SHA256 SSL CA,O="thawte, Inc.",C=US
* Server auth using Basic with user 'user'
> GET /a/gitweb?p=training/course.git;a=snapshot;h=9c1e2f9a8df8fa14e4db148437444ed4de00e2a2;sf=tgz HTTP/1.1
> Authorization: Basic YnVpbGQ6YnVpbGQ=
> User-Agent: curl/7.29.0
> Host: gerrit:8443
> Accept: */*
< HTTP/1.1 401 Unauthorized
< Date: Tue, 26 Jul 2016 07:06:21 GMT
< WWW-Authenticate: Digest realm="Gerrit Code Review", domain="https://gerrit:8443/", qop="auth", nonce="wDaor9GyM1NY2JLmV3VmjyuTCtk2fVKsWHiBSg==$"
< Content-Type: text/plain; charset=ISO-8859-1
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Content-Length: 12
{ [data not shown]
100    12  100    12    0     0     39      0 --:--:-- --:--:-- --:--:--    39
* Connection #0 to host gerrit left intact



Saša Živkov

unread,
Jul 26, 2016, 9:12:49 AM7/26/16
to Igor, Repo and Gerrit Discussion
On Tue, Jul 26, 2016 at 11:06 AM, Igor <igor.lit...@gmail.com> wrote:
The value of auth.gitBasicAuth is not set, so according to documentation it is false.

In that case your Gerrit server is doing a Digest authentication which you can also see from HTTP response.

Either set the auth.gitBasicAuth = true (and restart Gerrit afterwards) or provide the --digest option to your curl command.

I added /a prefix, now I get the "401 Unauthorized" error. Also I created http password and tried with http password as well, but the result is the same:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to gerrit port 8443 (#0)
*   Trying XX.XX.XX.XX...
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to gerrit (XX.XX.XX.XX) port 8443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_DHE_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
*       subject: CN=*. ...
*       start date: Jun 13 00:00:00 2016 GMT
*       expire date: May 10 23:59:59 2018 GMT
*       common name: *. ...
*       issuer: CN=thawte SHA256 SSL CA,O="thawte, Inc.",C=US
* Server auth using Basic with user 'user'

Is the username really 'user'?
 
> GET /a/gitweb?p=training/course.git;a=snapshot;h=9c1e2f9a8df8fa14e4db148437444ed4de00e2a2;sf=tgz HTTP/1.1
> Authorization: Basic YnVpbGQ6YnVpbGQ=
> User-Agent: curl/7.29.0
> Host: gerrit:8443
> Accept: */*
< HTTP/1.1 401 Unauthorized
< Date: Tue, 26 Jul 2016 07:06:21 GMT
< WWW-Authenticate: Digest realm="Gerrit Code Review", domain="https://gerrit:8443/", qop="auth", nonce="wDaor9GyM1NY2JLmV3VmjyuTCtk2fVKsWHiBSg==$"

The line above indicates that your Gerrit server performs digest authentication.

Igor

unread,
Jul 26, 2016, 10:06:22 AM7/26/16
to Repo and Gerrit Discussion, igor.lit...@gmail.com
First thanks for your support on this issue. 

I tried both adding --digest and setting auth.gitBasicAuth to true, but still can't download:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to gerrit port 8443 (#0)
*   Trying XX.XX.XX.XX...
* Connected to gerrit (XX.XX.XX.XX) port 8443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_DHE_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
*       subject: CN=*. ...
*       start date: Jun 13 00:00:00 2016 GMT
*       expire date: May 10 23:59:59 2018 GMT
*       common name: *. ...
*       issuer: CN=thawte SHA256 SSL CA,O="thawte, Inc.",C=US
* Server auth using Digest with user 'user'
> GET /a/gitweb?p=training/course.git;a=snapshot;h=9c1e2f9a8df8fa14e4db148437444ed4de00e2a2;sf=tgz HTTP/1.1
> User-Agent: curl/7.29.0
> Host: gerrit:8443
> Accept: */*
< HTTP/1.1 401 Unauthorized
< Date: Tue, 26 Jul 2016 13:33:43 GMT
< WWW-Authenticate: Digest realm="Gerrit Code Review", domain="https://gerrit:8443/", qop="auth", nonce="6L/kYfk7SkVeE4GWeUBJvsmbeWpwgC5N5GBRSA==$"
< Content-Type: text/plain; charset=ISO-8859-1
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Content-Length: 12
* Ignoring the response-body
{ [data not shown]
100    12  100    12    0     0     39      0 --:--:-- --:--:-- --:--:--    39
* Connection #0 to host gerrit left intact
* Found bundle for host gerrit: 0x1268080
* Re-using existing connection! (#0) with host gerrit
* Connected to gerrit (XX.XX.XX.XX) port 8443 (#0)
* Server auth using Digest with user 'user'
> GET /a/gitweb?p=training/course.git;a=snapshot;h=9c1e2f9a8df8fa14e4db148437444ed4de00e2a2;sf=tgz HTTP/1.1
> Authorization: Digest username="user", realm="Gerrit Code Review", nonce="6L/kYfk7SkVeE4GWeUBJvsmbeWpwgC5N5GBRSA==$", uri="/a/gitweb?p=training/course.git;a=snapshot;h=9c1e2f9a8df8fa14e4db148437444ed4de00e2a2;sf=tgz", cnonce="ICAgICAgICAgICAgICAgICAgICAgICAgMTMxODIzNzQ=", nc=00000001, qop=auth, response="162ce9c6ea14e753da6c66202da0aa99"
> User-Agent: curl/7.29.0
> Host: gerrit:8443
> Accept: */*
< HTTP/1.1 401 Unauthorized
< Date: Tue, 26 Jul 2016 13:33:43 GMT
* Authentication problem. Ignoring this.
< WWW-Authenticate: Digest realm="Gerrit Code Review", domain="https://gerrit:8443/", qop="auth", nonce="kiLAboOmbkrz0f2TV7qYRjZTCKnZ5j3RdzE3XA==$"
< Content-Type: text/plain; charset=ISO-8859-1
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Content-Length: 12
{ [data not shown]
100    12  100    12    0     0     39      0 --:--:-- --:--:-- --:--:--    39
* Connection #0 to host gerrit left intact

euni...@gmail.com

unread,
Feb 12, 2018, 9:15:03 PM2/12/18
to Repo and Gerrit Discussion
Hello Guys.

We have same problem.
Did you resolve this issue??

Thank you.

Igor

unread,
Feb 13, 2018, 5:04:35 AM2/13/18
to Repo and Gerrit Discussion
We had this problem back in 2016, I think our version of Gerrit was 2.13 or even 2.12. 

I checked both basic and digest authentication but was not able to figure out how to do it with curl. Didn't check this on 2.14.
Reply all
Reply to author
Forward
0 new messages