
GNU
wget
is a computer program that retrieves content from web servers. It supports downloading via HTTP, HTTPS, and FTP. This article mentions about downing authorized content from remote HTTP/FTP server without specifying a username and password.
Topic
-
How to download file from remote HTTP/HTTPS/FTP server without specifying username and password?
-
Using
wget
how to download files without specifying username and password? -
What is the use of
netrc
file? -
How to use
netrc
to store user name and password for specific remote server? -
How wget uses
netrc
file? -
ftp/lftp
command line download without specifying username and password
Solution
A netrc file is used to hold credentials necessary to login to your FTP, HTTP and other remote server and authorize access to data stored there. The netrc file contains configuration and autologin information for the FTP (File Transfer Protocol), HTTP client and other programs.
On a Mac, UNIX, or Linux system the netrc file should be named .netrc
(dot netrc) and on Windows it should be named _netrc
(underscore netrc). This file must be located in your home directory and keep the file secure by granting 600
permission i.e. the owner of the file has write access and others have no access to the file.
Setup or Configure netrc
-
Create a file called
.netrc
in your home directory$ touch ~/.netrc
-
Following three lines must be included in the file. The lines must be separated by either white space (spaces, tabs, or newlines) or commas:
machine <remote server IP or FQDN>
login <login name>
password <login password>
Sample netrc configuration
machine ftp.tekfik.com
login ftp_admin
password ftp_password
-
Another
netrc
example
machine ftp.tekfik.com login ftp_admin password ftp_password
- Note: Avoid leaving extra newlines at the end of your netrc file. Some applications may interpret these as missing additional entries or premature EOFs.
Download with wget command
$ wget ftp://ftp.tekfik.com/data/file.txt
$ wget http://www.tekfik.com/content/file.txt