【发布时间】:2011-12-18 19:26:27
【问题描述】:
我们想使用 mercurial 进行 Web 开发,但我们不能(也不想)在共享主机上安装 mercurial。我们尝试使用here 中提到的 wget,但出现 401 错误。 凭据和链接正确(为安全起见已修改)。
有没有办法从命令行下载源码?
这是错误还是我做错了什么?
回复如下:
$ 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.
采取 2:
感谢帮助...我将 http 更改为 https 和用户用户和密码属性:
浏览器工作正常,Wget 不行...
$ 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.
采取 3:
我也尝试过 curl,但我收到错误消息: 禁止 (403) CSRF 验证失败。请求中止。
【问题讨论】:
-
尝试直接访问 HTTPS 网址。您正在访问 HTTP,而 wget 很可能不会通过重定向传递嵌入 url 的凭据。
-
改用
--user和--password命令行选项。 -
我用 curl 得到了它: curl --digest --user username:password bitbucket.org/user/repo/get/tip.zip -o test.zip bitbucket 的回答:bitbucket.org/site/master/issue/3225/… 您好 Esa,我们实际上不支持基本auth 用于下载源包。您需要使用摘要身份验证。另外,据我了解, wget 的摘要身份验证实现存在错误。您可以将 curl 与 --digest 标志和 -o 标志一起使用来指定输出文件。干杯,迪伦