lftp a sophisticated ftp client – exploring the site

lftp: ftp client

lftp is a sophisticated ftp client that implements the following features:

  • Handles different protocols: ftp, ftps, sftp, http, hftp, fish and bittorrent (https and ftps protocols will be available only if lftp was compiled with GNU TLS or OpenSSL libraries).
  • Every operation is reliable, that is any non-fatal error is handled properly and the operation is repeated, for example if a downloading breaks, it will be restarted from where it was, even if the ftp server does not support REST command, lftp will try to retrieve the file from the beginning until the download is completed.
  • It allows you to run tasks in the background (&).
  • It allows grouping commands using parentheses and launches them in background.
  • You can put a command in background using Ctrl-z an get it back with the wait or fg command (fg an alias for wait).
  • Listing running jobs, through command jobs.
  • Commands can be executed conditionally based on termination status of previous command (&&, ||).
  • Autocomplete using Tab key, similar to bash.
  • If you exit lftp when some jobs are not finished yet, lftp will move itself to nohup mode in background.
  • It allows you to update, upload or download a full directory through the mirror option.
  • With the command at you can schedule tasks.
  • The command queue allows you to queue commands for sequential execution.

lftp reads configuration directives from /etc/lftp.conf, ~/.lftprc and ~/.lftp/rc where you can put aliases and set commands.

Connect to a public ftp site

$ lftp ftp://openbsd.cs.toronto.edu
$ lftp
> open openbsd.cs.toronto.edu

Connect to a restricted ftp site

There are several ways to connect to a restricted ftp site, here are 4 of them. If you not specify the password, lftp will request it (recommended method)

$ lftp user[:password]@ftp.mysite.com
$ lftp ftp.mysiteftp.com
> user username [password]
$ lftp
> open ftp.mysite.com
> user username [password]
$ lftp
> open username[:password]@ftp.mysite.com

List the remote content

> ls

List local content

> !ls

Show current remote URL

> pwd

Show current local working directory

> lpwd

Change remote directory

> cd remote-dirname

Change local directory

> lcd local-dirname

lftp a sophisticated ftp client, 1 (4)

2 thoughts on “lftp a sophisticated ftp client – exploring the site”

  1. lftp supports FTP over SSL which is the mean reason I use it in scripts.

    For anyone interested, tweak your ~/.lftprc to something like:

    set ftp:ssl-allow true
    set ftp:ssl-force true
    set ftp:ssl-protect-data true
    set ftp:ssl-protect-list true
    set ssl:verify-certificate false #for self-signed certs
    set ssl:priority “NORMAL:-SSL3.0:+TLS1.0:+TLS1.1:+TLS1.2”

    And you have a superb FTPES client that can be easily scripted.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.