Wget Password: How to use passwords securely with wget

Before the Wget 1.12 version, in order to fetch the authenticated http/ftp pages, we had to provide the password in clear text which was quite insecure. Since that version, a new option, --ask-password, has been included which prompts the user to fill the password in a secure manner(hidden like unix passwd).

The regular way to fetch authenticated pages is done by using the --user and --password options. e.g.

[shredder12]$ wget --user=chia --password=secret http://foo.bar/somepage.php

As you can see the user has to enter the password in clear text. By using --ask-password, we can avoid this scenario.

[shredder12]$ wget --user=chia --ask-password http://foo.bar/somepage.php
password for chia:

Although, this will require the user to be present in order to enter the password.

You would have figured it out by now that this method won't work in case of scripts, where no user would be present to enter the password. The work around in such cases is to enter the username and passwork in the wget's configuration file - wgetrc. Even this method is a good way to avoid entering passwords in scripts. All you need to do is enter these two options in either ~/.wgetrc or /etc/wgetrc file.


If you want to provide separate password for http or ftp then use the --http-user, --http-password and --ftp-user, --ftp-password options. Similarly, the wgetrc's option would become


Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.