How To Use wget With Username and Password for FTP / HTTP File Retrieval

by on May 2, 2008 · 25 comments· LAST UPDATED May 2, 2008

in , ,

Q. How do I use wget ftp / http client tool to download files from password protected web page?

A. wget command supports username and password combo for both FTP and HTTP file retrieval.

Pass following option to wget command:
--user=userName: Your FTP/HTTP username
--password=passWord : Your HTTP/FTP password

These parameters can be overridden using the --ftp-user and --ftp-password options for FTP connections and the --http-user and --http-password options for HTTP connections.

Download a file called foo.pdf from theos.in:
$ wget --user=vivek --password='myPassword' http://theos.in/protected/area/foo.pdf

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 25 comments… read them below or add one }

1 lakshminarayanan May 14, 2008 at 1:17 pm

wow…that was cool!

Reply

2 chadido August 8, 2009 at 7:36 am

thats great u saved me

Reply

3 Mauricio Hernandez August 21, 2009 at 3:21 am

Could this be used for rapidshare?

Reply

4 Vagin August 24, 2009 at 12:49 am

Didn’t work for me. I am on a windows machine. Not sure if that makes a diffrence.

Reply

5 iqueen November 18, 2009 at 11:35 am

gnuwin32.sf.net
wget 1.12
–ftp-user=
–ftp-password=

Reply

6 Asterisk January 12, 2010 at 9:30 am

Works Like a charm!!!
tx.

Reply

7 meitham July 10, 2010 at 12:40 pm

I need to download a file from my server on another machine with wget, using -p password as an argument is not an option since people could simply find my password with a ps command! Do you know anyway I could force wget to ask for my password after typing the command? like when do mysql -u root -p and it will ask you for the root password?
thanks

Reply

8 Vikas August 1, 2014 at 1:36 pm

yes, its possible:

wget –user=username–ask-password http://abc.com/file.exe

Reply

9 Rahman August 25, 2010 at 6:03 am

Works Like a charm!!!
tx. [2]

Reply

10 Tony Palmer November 2, 2010 at 4:04 pm

wget does not work directly if the site redirects to form based login page, i.e. no HTTP 401 returned

Reply

11 Mohamed Jameer March 24, 2011 at 7:24 am

Its Working fine, Thx a lots..

Reply

12 Chris Shennan August 4, 2011 at 9:09 am

As easy at that! This made downloading a large XML file much easier than using a browser which ended up crashing 9 out of 10 times.

Many thanks.

Chris.

Reply

13 Reddy Siva Saran K January 18, 2012 at 4:39 am

I tried the following command which gave a Error Response
The Response is
Resolving cambuild.qalab.cam.novell.com… 164.99.129.35
Connecting to cambuild.qalab.cam.novell.com|164.99.129.35|:80… connected.
HTTP request sent, awaiting response… 403 Forbidden
2012-01-18 10:07:51 ERROR 403: Forbidden.

Have any one faced a similar issue and if yes can you let me know how to come out from this

Reply

14 John March 19, 2012 at 1:04 pm

I have the same problem. Any ideas on how to fix?

Reply

15 Josh May 13, 2012 at 11:12 pm

Thank you so much, this was exactly what I needed, and it works wonderfully!

Reply

16 Pawan July 24, 2012 at 10:23 am

Hi Reddy,
You must have got your answer by now, posting info hopeing it would help others

Connecting to cambuild.qalab.cam.novell.com|164.99.129.35|:80… connected.
HTTP request sent, awaiting response… 403 Forbidden
2012-01-18 10:07:51 ERROR 403: Forbidden.

If you see the error above, it show your machine succesfully connected to remote host on port 80, however could not find the page you have requsted for403 Forbidden.
Hope this clarify.

Reply

17 fsilva June 26, 2014 at 6:37 pm

This doesnt mean the page could not be found that’s a 404 error. This mean the user who attempted to login does not have the permission to access any further. Therefore “Forbidden” request error is thrown.

Reply

18 sujith August 28, 2012 at 10:05 am

Working Perfectly Thanks a lot

Reply

19 Parthiban September 17, 2012 at 9:30 am

I want to download two of three files (file-abc.zip, file-xyz.zip, sample.zip) from a ftp server. How can I use wget like————- file*.zip in a shell script.

Reply

20 kelvin kalaria October 15, 2012 at 3:26 pm

very very useful command for me

Thanks a ton..

Reply

21 Emile July 10, 2013 at 10:00 am

You can also use this:

wget ftp://userName:passWord@wwww.example.com/file.pdf

Reply

22 Nabil September 6, 2013 at 7:39 pm

Add a space before the command to prevent the command from being stored on your bash history.

Reply

23 Tyzoid September 20, 2013 at 8:28 pm

To protect yourself from having your password in your terminal history, you can use the following:

read -s q; wget http://example.com/path/to/file --user=username --password="$q";

Reply

24 Tyzoid September 20, 2013 at 8:30 pm

Remember to set q to null again afterwards!

q="";

Reply

25 امیر محمد October 1, 2013 at 1:44 pm

واقعا ممنون به دردم خورد

thanks a lot very Nice :x

Reply

Leave a Comment

Tagged as: , , , , , , ,

Previous Faq:

Next Faq: