lftp: file tranfers with a very smart tool!
Published in
3 min readJul 17, 2021
lftp is a very nice tool that can simplify file transfer operations that would be complicate to do with shell scripting
lftp generic syntax
- protocol: can be ftp,sftp,http,https
- username: the ftp username, needs to have access to the directories you want to get/put files.
- password: if the password contains characters like @,! that the shell might try to parse them try to escape them like this \! \@
- host: the server
- command: can be common ftp commands like ls mkdir etc, but can be lfpt specific like mirror that we will see some examples, commands must be semicollon separated.
$ lftp protocol://username:password@host -e "command1;command2"
How to mirror an sftp directory to localhost (get)
- mirror: instructs lftp to copy the files from the ftp server to localhost
- source: is a directory on the ftp host
- target: is a directory on local host
One thing you have to be aware is that you need to run lftp as a user which have access rights to the target directory or else copy will fail.
$ lftp sftp://username:password@host -e "mirror source target"