问题
We would like to use mercurial for web development, but we can't (and don't want to) install mercurial on a shared host. We try to use wget as mentioned here, but I get 401 error. Credentials and link are correct (modified for security).
Is there a way to download source from command line?
Is this bug or am i doing something wrong?
Response below:
$ wget _http://xxxx:yyyyyyy@bitbucket.org/username/repo/get/be51983f6357.zip
--2011-10-31 00:26:50--
http://username:password@bitbucket.org/username/repo/get/be51983f6357.zip
Resolving bitbucket.org... 207.223.240.182, 207.223.240.181
Connecting to bitbucket.org|207.223.240.182|:80... connected.
HTTP request sent, awaiting response...
301 Moved Permanently Location: https://bitbucket.org/username/repo/get/be51983f6357.zip [following]
--2011-10-31 00:26:51--
https://bitbucket.org/username/repo/get/get/be51983f6357.zip
Connecting to bitbucket.org|207.223.240.182|:443... connected.
HTTP request sent, awaiting response...
401 UNAUTHORIZED Authorization failed.
Take 2:
Thanx for help... i changed http to https and user user & password attributes:
Browser works fine, Wget does not...
$ wget --verbose --user=XXXXX --password=YYYY https://bitbucket.org/ekku/REPO/get/aabbccddeee.zip
--2011-10-31 18:27:10-- https://bitbucket.org/ekku/REPO/get/aabbccddeee.zip
Resolving bitbucket.org... 207.223.240.182, 207.223.240.181
Connecting to bitbucket.org|207.223.240.182|:443... connected.
HTTP request sent, awaiting response... 401 UNAUTHORIZED
Failed writing HTTP request: Bad file descriptor.
Retrying.
Take 3:
I also tried curl, but i get error message: Forbidden (403) CSRF verification failed. Request aborted.
回答1:
I got it working with curl:
curl --digest --user username:password https://bitbucket.org/user/repo/get/tip.zip -o test.zip
Answer from Bitbucket: Issue #3225 - Commanline download compressed tip
Hi Esa, We don't actually support basic auth for downloads of source bundles. You need to use digest auth. Also, from what I understand, wget has a bug with its digest auth implementation. You can use curl with the --digest flag and the -o flag to specify your output file. Cheers, Dylan
回答2:
You should not use bitbucket over http
; always use https
. That should get rid of the additional redirect that you're seeing.
Also use the command line options --user
and --password
to specify the authentication for wget
; SSL probably doesn't allow to add user and password to the URL because the server part (between ://
and the next /
) is sent to the server in plain text.
来源:https://stackoverflow.com/questions/7955290/wget-compressed-tip-from-bitbucket-mercurial