What Is the Correct Wget Command Syntax for Https with Username and Password?

I would like to download a file remotely with this URL using wget:


The site test.mydomain.com requires a login. I would like to download that file in my another server using this command but it does not work (does not completely download the file):

wget --user=myusername --password=mypassword 

If my username is myusername and password is mypassword what would be the correct wget syntax?

The following are the return messages after I type the above command:

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:  [following]
--2013-01-30 02:01:32--  
Reusing existing connection to test.mydomain.com:443.
HTTP request sent, awaiting response... 302 Found
Location:  [following]
--2013-01-30 02:01:32--  
Reusing existing connection to test.mydomain.com:443.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `myfile.zip'

Am I missing something? Please help. Thanks.

9

4 Answers

By specifying the option --user and --ask-password wget will ask for the credentials. Below is an example. Change the username and download link to your needs.

wget --user=username --ask-password 
3

I have found that wget does not properly authenticate with some servers, perhaps because it is only HTTP 1.0 compliant. In such cases, curl (which is HTTP 1.1 compliant) usually does the trick:

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

5

It's not that your file is partially downloaded. It fails authentication and hence downloads e.g "index.html" but it names it myfile.zip (since this is what you want to download).

I followed the link suggested by @thomasbabuj and figured it out eventually.

You should try adding --auth-no-challenge and as @thomasbabuj suggested replace your password entry

I.e

wget --auth-no-challenge --user=myusername --ask-password 
2

You could try the same address with HTTP instead of HTTPS. Be aware that this does use HTTP instead of HTTPS and only some sites might support this method.

Example address:

wget

*notice the http:// instead of https://.

This is probably not recommended though :)

If you can, try use curl.


EDIT:

FYI an example with username (and prompt for password) would be:

curl --user $USERNAME -O

Where -O is

 -O, --remote-name
              Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut off.)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest