Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

wget http://<user>:<pass>@serveradress

But wget responds: invalid port

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

share|improve this question

3 Answers 3

up vote 37 down vote accepted

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

wget --user user --password pass http://serveraddress/

From man wget:

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.

share|improve this answer
I prefer the --ask-password option described by Nabil Kadimi's answer. It has you enter the password invisibly on another line and avoids storing it in your shell history. –  Kevin Apr 8 '14 at 1:23
@Kevin You can avoid storing it in the shell history by starting the line with at least one space (as shown by Nabil). If the password/resource is sensitive, then you should worry more about the unencrypted HTTP/FTP/whatever connection than storing it on your disk. –  Lekensteyn Apr 8 '14 at 8:58

You have 3 options and here there are in no specific order other than guts feeling:

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

me@machine:~$ wget --user=remote_user --password=SECRET

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

2/ Password is visible to anyone looking behind your shoulders

me@machine:~$  wget --user=remote_user --password=SECRET

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.

3/ Password is not visible to anyone including you

me@machine:~$ wget --user=remote_user --ask-password
Password for user `remote_user': [SECRET (not visible)]
share|improve this answer
don't forget to add the following option --no-check-certificate I.E: wget --no-check-certificate --user user --password pass http://serveraddress/ –  Abdennour TOUMI Jan 5 '14 at 5:10
While it is not visible in history, it is visible to all who conduct a ps, top, htop or similar command while the process is running. –  ken May 22 at 20:04

I don't think you can reliably use the user:pass@name syntax there; wget has separate command line options for those instead, so is probably naively parsing the string after the : as a port number.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.