How do I provide a username and password to wget?

I've tried to connect to a server via wget:

wget 

But wget responds: invalid port

I know that the server accepts incoming traffic at port 80. How can I fix this issue?

1

6 Answers

Wget interprets <pass>@serveraddress as port. To specify a username and password, use the --user and --password switches:

wget --user user --password pass 

From man wget:

--user=user

--password=password

Specify the username user and password password for both FTP and HTTP file retrieval. 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.

5

You have 3 options here. They are in no specific order other than gut feeling:

1. Password is visible to anyone (using the command history)

wget --user=remote_user --password=SECRET ftp://

The password will also be visible in ps, top, htop and similar.

2. Password is visible to anyone looking behind your shoulders

 wget --user=remote_user --password=SECRET ftp://

Notice the white space before the command, it prevents saving it to your history.

The password will also be visible in ps, top, htop and similar. (Thanks user412812)

3. Password is not visible to anyone including you

wget --user=remote_user --ask-password ftp://
Password for user `remote_user': [SECRET (not visible)]
2

You can also store the username and password in the file ~/.wgetrcand change the permissions of that file so that only your user can read it:

File ~/.wgetrc:

user=john
password=SEcrEt

... and then

chmod 600 ~/.wgetrc

Note, however, that user root can still peek into that file and read the password.

From the manpage:

To prevent the passwords from being seen, use the --use-askpass or store them in .wgetrc or .netrc, and make sure to protect those files from other users with "chmod". If the passwords are really important, do not leave them lying in those files either --- edit the files and delete them after Wget has started the download.

This should work (don't miss the quotes)

wget '

Example for my access to the builds on ftp server

wget 'ftp://DOMAIN\thomas:dasbleibtgeheim@

You can provide authentication credential via --user=USERNAME and --password=PASSWORD; based on the man wget, the command can be overridden using the --http-user=USERNAME and --http-password=PASSWORD for http connection and the --ftp-use=USERNAME and --ftp-password=PASSWORD for ftp connection.

The command could have used --http-user and --http-password instead of --user and --password. In case of ftp request the options are --ftp-user and --ftp-password.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like