Linux Lftp Client Tutorial For Ftp, Http, Sftp, Https, Ftps, Fish Potocols
Lftp is a powerful command line tool which supports FTP, HTTP, SFTP, FISH, TORRENT protocols for file and data transfer. As we can see it supports popular data and file transfer protocols. It uses GNU TLS or OpenSSL for SSL/TLS encryption. In this tutorial we will look installing and different examples with
lftp is provided Linux distributions from official repositories. We can install it for
yum based distros like Fedora, RedHAT, CentOS with the following command.
$ sudo yum install lftp -y
another alternative is installing it into
apt based distros like Debian, Ubuntu, Kali, Mint.
$ sudo yum install lftp -y
Syntax and Help
lftp provides very simple syntax. We can show syntax and help information with the
-h option like below.
$ lftp -h
lftp tool have very detailed configuration file. This configuration file can be used for specify alias, ssl configuration, proxy configuration, anonymous password, etc. Default path and name of the configuration file is
/etc/lftp.conf. We can print this configuration file like below. In order to edit this file we need root privileges.
$ cat /etc/lftp.conf
lftp also provides an interactive shell like FTP connections. We just need to issue the
lftp command where we will enter to the interactive shell.
Now we can start the action. We will connect to an FTP server with the
lftp command. We just need to specify the protocol which is FTP in this case and the IP address or host name of the server. In this example we will connect to
$ lftp ftp://ftp.metu.edu.tr
Another supported protocol is SFTP. SFTP is very similar with the FTP protocol. But the
S makes the SFTP secure which means the network traffic is encrytpted with SSL/TLS. Other things are the same with FTP. In this example we will connect using
sftp:// of IP address 192.168.1.1 .
$ lftp sftp://192.168.1.1
Disable SSL Certification Verification
There are a lot of configuration about
lftp . One of the most error prone configuration is SSL and SSL verification. As we know SSL certificates are approved by the authorities. But in some cases servers can use unapproved certificates. This will create following error.
Fatal error: Certificate verification: Not trusted
In order to prevent this connection error we need to turn of the SSL certificate verify. Following configuration line will disable SSL verification. This configuration line can be put into global configuration file
/etc/lftp.conf or into user local configuration file
set ssl:verify-certificate no
In corporate environment proxy is popular connection technology. In this case we need to specify the proxy configuration to the
lftp . We will set proxy configuration by using bash environment variables. We can set HTTP proxy like below. This line should be put into global configuration file
/etc/lftp.conf or user local configuration file
set http:proxy 192.168.1.1:8080