Wget compressed tip from Bitbucket (mercurial)

2019-07-16 14:11发布

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.

2条回答
对你真心纯属浪费
2楼-- · 2019-07-16 14:39

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.

查看更多
祖国的老花朵
3楼-- · 2019-07-16 14:50

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

查看更多
登录 后发表回答