The default command line ftp client in most UNIX distributions do not support recursive downloads, even though recursive downloads is a basic feature in most GUI based ftp clients. But if you do not have access to the X-Windows or GUI, there are alternative ways to achieve the same result from the command line.

Recursive FTP Download

One alternative method is to use the wget command.

ibrahim@anfield:~$ mkdir dnld ; cd  dnld
ibrahim@anfield:~/dnld$ wget --user=username --password=password ftp://ftpsite.com/directory/to/download/

If your wget client does not support the ‘–user’ and ‘–password’ arguments, you must modify the FTP URL to include the login details.

ibrahim@anfield:~$ mkdir dnld ; cd  dnld
ibrahim@anfield:~/dnld$ wget ftp://username:password@ftpsite.com/directory/to/download/

Another alternative method is to use the lftp command for the recursive FTP download. Login to the FTP site, change to the required remote directory and use the mirror option to start the recursive download.

ibrahim@anfield:~$ mkdir dnld ; cd  dnld
ibrahim@anfield:~/dnld$ lftp ftp://ftpsite.com/
lftp ftpsite.com:~> user username
Password:
lftp ftpsite.com:~> cd /directory/to/download/
lftp ftpsite.com:~/directory/to/download/> mirror .
Recursive FTP Upload

To perform a recursive FTP upload, lftp is the only option for now as wget does not allow FTP uploads.

The mirror -R option in lftp can be used for the upload.

ibrahim@anfield:~$ cd  upld
ibrahim@anfield:~/upld$ lftp ftp://ftpsite.com/
lftp ftpsite.com:~> user username
Password:
lftp ftpsite.com:~> cd /directory/to/upload/
lftp ftpsite.com:~/directory/to/upload/> mirror -R .
Recursive FTP in Windows

Both wget and lftp are available in Windows as part of the Cygwin environment.

Ibrahim is a (Software Engineer && Mobile Telecom Network professional). A technology enthusiast with great interest in *NIX (Unix, Linux), Android and open source projects.