Enhanced

Which LFTP?

If you want to use LFTP with FTPS, you might need to compile the package with SSL support yourself. Use the command line to check whether this is necessary by entering the

which lftp

command to determine where LFTP has been installed. After calling

ldd /<path>/<to>/lftp

check its output to see whether one of the lines starts with libssl (Figure 1); for example:

$ ldd /usr/local/bin/lftp | grep ssl
Figure 1: Using FTPS will not work without libssl support.

If this is not the case, and you want to use FTPS instead of SFTP, follow the instructions in the "DIY LFTP" box.

DIY LFTP

On Debian, you need to install the following dependencies:

  • libgnutls30
  • libgcc1
  • libreadline-dev
  • libssl-dev
  • libtinfo5
  • libunwind8
  • libghc-zlib-dev

Depending on the version of the system you are using, you might need other versions of these packages. If further software is missing, entering ./configure will usually let you know. Build LFTP as shown below with the usual three-card trick – ./configure, make, and make install – and use ldd to test your home-grown LFTP version for SSL support.

$ wget http://lftp.yar.ru/ftp/lftp-4.8.0.tar.gz$ tar xfz lftp-4.8.0.tar.gz
$ cd lftp-4.8.0
$ ./configure --with-openssl=/usr/lib
$ make
$ sudo make install
$ ldd /usr/local/bin/lftp | grep ssl
  libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fbe89dbd000)

At system startup, LFTP will search the /etc/lftp.conf, ~/.lftprc, and ~/.lftp/rc files (in that order) for configuration. Directives that you create in the home directory take precedence over the global configuration in the /etc directory. The instructions always start with set and follow the

set <Option>:<Switch>[on|off]

scheme.

Practice

For test purposes, it is best to use two local computers that serve as the server and client. LFTP will behave in the same way as if you were using remote servers, but it will be easier to locate sources of problems and errors. Unless you specify otherwise, LFTP uses the SFTP protocol. Ports other than standard port 21 are entered at the end of the connection command in the form :<port>.

For more feedback, add the -d (debug information) option to the lftp call. The -h (--help) parameter offers little help when it comes to the application's options. An intelligible version of the LFTP man page can be found on the Lifewire website [3].

To get used to the LFTP shell, first download or upload files from the server. To do this, log on to the server with the lftp <user>@[<FQDN>|<IP>] command; for example:

lftp ft@192.168.178.123

After the connection is established, you are in the LFTP shell.

The ls command lists the current directory content on the server. With a preceding exclamation mark (!), you can redirect the command to the client; !ls shows the contents of the client's current local working directory (Figure 2). Some commands can be executed with a preceding small l (ell, for "local") on the client, and other commands can be preceded by either switch. Usage is not completely consistent. To simplify things, you can define command aliases to suit your own requirements.

Figure 2: Bash commands with preceding exclamation marks act on the client.

Up and Down

To upload a file from the client to the server, use the put command, to which you add the name of the file in question (put <file>). The -d parameter used for logging in shows you what is happening in the background in detail. If you want to put the file in a certain directory, go there with the cd command and then run put.

Following the same pattern, get lets you download a file. However, with pget, LFTP offers an alternative that distributes the data transfer over several parallel connections, thus speeding up the download on servers with slow connections. In practice, you would first change to the directory in which you want to store the downloaded file !cd or lcd followed by get <file> or pget <file>.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • SystemRescueCd

    The SystemRescueCd live system contains numerous tools that you can use to recover deleted files or a defective system.

  • Finnix 93.0 Fresh from Debian Testing

    Finnix, a LiveCD Linux distro for system administrators, is available in version 93.0.

  • Command Line: FTP and NcFTP

    FTP and NcFTP are both FTP clients for the command line. While FTP only has basic file transfer functionality, NcFTP has a whole bunch of additional features.

  • Command Line: Yafc

    The console-based yafc client gives users a convenient, simple, and interactive approach to exchanging data with ftp and SSH servers.

  • FileZilla

    High-performance GUI-based ftp clients for Linux are hard to find. The graphical FileZilla ftp client closes the gap.

comments powered by Disqus