If you are dealing with ftp, ftps or sftp file transfer very likely you already have some favorite client for that purpose. I usually use FileZilla which works fantastic in graphical interface regardless it is on Linux/FreeBSD/MacOS or even Windows. For cli my first choice is lftp[1] whenever it is possible. It is maybe not easy to start with this program but it is really powerful. I highly recommend to spend a few moments to familiarize yourself with this product. It will pay off in the future, especially at the moment you will need to resume downloading 100GB file from ftps server like me recently 🙂
lftp is available under GNU license:
You can use lftp both, using interactive command or via script.
To start, assuming it is already installed just type lftp
If you are familiar with regular ftp server, you will be surprised with lots of lftp options:
With lftp command prompt you can set
ftp option and then connect to the server with command connect
.
If you need more detailed information, lftp can be run with option -d
Example (for ftps server):
lftp -d
The same options can be set in file ~/.lftprc.
For script processing program use option -f (lftp -f scriptfile
)
The simplest scriptfile can have the following content:
open SERVER
user USERNAME PASSWORD
ls
or
open SERVER
user USERNAME PASSWORD
mirror --verbose -c --use-pget-n=3 DIRECTORYTODOWNLOAD .;
Of course, lftp provide much more functionality, including file download resume (-c
).
Documentation:
[1] https://lftp.yar.ru/lftp-man.pdf
[2] https://unix.stackexchange.com/questions/592624/how-to-connect-to-server-with-tls-using-lftp
[3] https://www.librebyte.net/en/ftp-en/lftp-fatal-error-certificate-verification-not-trusted/
[4] https://superuser.com/questions/623236/simple-command-to-connect-to-ftps-server-on-linux-command-line
[5] https://danielhoherd.com/tech-notes/jdupes/
[6] https://serverok.in/download-all-files-from-ftp-server-using-lftp
[7] https://x8t4.com/12-lftp-commands-for-managing-files-with-examples/
[8] https://lftp.yar.ru/lftp-man.pdf
[9] https://www.reddit.com/r/linux/comments/4anfej/lftp_segmented_downloads_made_simple/
[10] https://ourcodeworld.com/articles/read/788/how-to-download-a-remote-directory-with-lftp-sftp-using-a-lftp-script
No Comments