Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to download a folder using wget on the Terminal (I'm usin a Mac if that matters) because my ftp client sucks and keeps timing out. It doesn't stay connected for long. So I was wondering if I could use wget to connect via ftp protocol to the server to download the directory in question. I have searched around in the internet for this and have attempted to write the command but it keeps failing. So assuming the following:

ftp username is: ftp host is: ftp password is: somepassword

I have tried to write the command in the following ways:

wget -r

wget -r

When I try the first way I get this error:

 Bad port number.

When I try the second way I get a little further but I get this error:

Connecting to||:21... connected.
Logging in as serveradmin ... 
Login incorrect.

What could I be doing wrong?

share|improve this question
up vote 1 down vote accepted

So you are running a wget command, but can not issue wget -h? :)

FTP options:
       --ftp-user=USER         set ftp user to USER.
       --ftp-password=PASS     set ftp password to PASS.

So your command becomes

wget -r --ftp-user="" --ftp-password=somepassword

You most likely will have to put " " around the username because it contains @ character

share|improve this answer
It totally worked. Thank you so much. I've been racking my head for a couple of hours trying to get this exact command to work. I asked this same question at Stackoverflow & someone suggested that I could use the scp instead & it works on Media Temple because I have ssh access but I feared it wouldn't work on other hosting services without ssh access. Final question: what flag could I put so that it doesn't download every folder in between? E.g. suppose the path to the folder is this: /domains/mydomain/html/webdir and I just want webdir/ to be downloaded and not domains/, mydomain/ and html/? – user41157 Apr 21 '10 at 21:20
Glad i could help! To avoid downloading "parent" folders, use -np (same as --no-parent) option. It should do what you need. – solefald Apr 21 '10 at 21:50
+1 for "So you are running a wget command, but can not issue wget -h?". – John Gardeniers Apr 21 '10 at 22:11
I did look at the command line options but I guess I had no patience to try too many configurations before getting frustrated. I'd rather ask questions first to get an idea. – user41157 Apr 22 '10 at 0:05

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.