首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >对于带有用户名和密码的HTTPS,正确的wget命令语法是什么?

对于带有用户名和密码的HTTPS,正确的wget命令语法是什么?
EN

Stack Overflow用户
提问于 2013-01-30 10:12:05
回答 4查看 192K关注 0票数 45

我想使用此URL使用wget远程下载文件:

代码语言:javascript
代码运行次数:0
运行
复制
https://test.mydomain.com/files/myfile.zip

站点test.mydomain.com需要登录。我想使用此命令在我的另一台服务器上下载该文件,但它不起作用(不能完全下载该文件):

代码语言:javascript
代码运行次数:0
运行
复制
wget --user=myusername --password=mypassword https://test.mydomain.com/files/myfile.zip

如果我的用户名是myusername,密码是mypassword,那么正确的wget语法是什么?

以下是我输入上述命令后的返回消息:

代码语言:javascript
代码运行次数:0
运行
复制
Resolving test.mydomain.com (test.mydomain.com)... 123.456.789
Connecting to test.mydomain.com (test.mydomain.com)|123.456.789|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://test.mydomain.com/login/unauthorized [following]
--2013-01-30 02:01:32--  https://test.mydomain.com/login/unauthorized
Reusing existing connection to test.mydomain.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://test.mydomain.com/login [following]
--2013-01-30 02:01:32--  https://test.mydomain.com/login
Reusing existing connection to test.mydomain.com:443.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `myfile.zip'

我是不是遗漏了什么?请帮帮忙。谢谢。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-01-30 10:19:47

通过指定选项--user和-- ask -password,wget将要求提供凭据。下面是一个例子。根据需要更改用户名和下载链接。

代码语言:javascript
代码运行次数:0
运行
复制
wget --user=username --ask-password https://xyz.com/changelog-6.40.txt
票数 88
EN

Stack Overflow用户

发布于 2013-06-12 02:26:33

我发现wget在某些服务器上不能正确地进行身份验证,可能是因为它只兼容HTTP 1.0。在这种情况下,curl (与HTTP 1.1兼容)通常可以做到这一点:

curl -o <filename-to-save-as> -u <username>:<password> <url>

票数 23
EN

Stack Overflow用户

发布于 2016-01-18 21:30:03

这并不是说你的文件被部分下载了。它无法通过身份验证,因此会下载例如"index.html“,但它将其命名为myfile.zip (因为这是您想要下载的内容)。

我关注了@thomasbabuj建议的链接,并最终找到了它。

您应该尝试添加--auth-no-challenge,并建议替换您的密码条目

I.e

代码语言:javascript
代码运行次数:0
运行
复制
wget --auth-no-challenge --user=myusername --ask-password https://test.mydomain.com/files/myfile.zip
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14595554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档