User:Wuseman/lftp

From Gentoo Wiki
Jump to:navigation Jump to:search

LFTP is a sophisticated file transfer program supporting a number of network protocols (ftp, http, sftp, fish, torrent). Like BASH, it has job control and uses the readline library for input. It has bookmarks, a built-in mirror command, and can transfer several files in parallel. It was designed with reliability in mind.

Installation

USE Flags

USE flags for net-ftp/lftp A sophisticated ftp/sftp/http/https/torrent client and file transfer program

convert-mozilla-cookies Install the convert-mozilla-cookies script and its run-time dependencies
gnutls Prefer net-libs/gnutls as SSL/TLS provider (ineffective with USE=-ssl)
idn Enable support for Internationalized Domain Names
nls Add Native Language Support (using gettext - GNU locale utilities)
socks5 Add support for the socks5 proxy
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
verify-file Install the verify-file script and its run-time dependencies

Emerge

root #emerge --ask lftp

Usage

FXP with 20 Threads

Perform File eXchange Protocol (FXP) between two sites with 20 threads:

user $lftp -e "set ftp:use-fxp true ;mirror -R -P20 ftp://user1:pass1:site1:port:/path ftp://user1:pass1:site1:port:/path" -d

Multi-threaded Download

Download files from websites using multiple threads:

user $lftp -c "pget -n 10 http://example.com/foo.bar"

Directory Mirroring

Mirror a local directory structure to an FTP server:

user $lftp -u 'login,passwd' -e "mirror reverse /my/from/dir/ /ftp/target/dir/" ftp://site.com/

Apache Index Mirroring

Mirror a directory structure from websites with Apache-generated file indexes:

user $lftp-e "mirror -c" http://example.com/foobar/

Speed Test

Test internet speed by downloading a file:

user $lftp -e 'pget http://address_to_file; exit;'

Multi-segment File Download

Perform multi-segment file downloading:

user $lftp -u "user,pass" ftp://site.com -e 'pget -c -n 6 file'

Multi-segment Directory Download

Perform multi-segment directory downloading:

user $lftp -u "user,pass" ftp://site.com/ -e 'mirror -c parallel=3 use-pget -n=5 "Some folder"'

Directory and File Listing

Get a directory and file tree listing from an FTP server:

user $lftp -u "user,pass" ftp://site.com/ -e "du -a;exit" > server-listing.txt

Fast SSH Sync

Perform the fastest segmented parallel sync of a remote directory over SSH:

user $lftp -u "user,pass" -e "set sftp:connect-program 'ssh -a -x -T -c fooo -o Compression=no'; mirror -v -c loop use-pget-n=3 -P 2 /remote/dir/ /local/dir/; quit" sftp://remotehost:22

Advanced Usage

LFTP's capabilities extend beyond basic file transfers. It can be used to automate complex file transfer workflows across multiple servers. The following script demonstrates how to use LFTP to transfer files between multiple FTP servers. It allows you to define a source server from which files will be sent, along with multiple destination servers where the files will be transferred. The script initiates file transfers from the source server to each of the destination servers individually, ensuring that files are successfully delivered. Additionally, it enables file exchange between the destination servers themselves, allowing for

efficient and seamless distribution of files among all connected servers.

Here is a simple map for how it is done:

  
     Source Server
         (source.example.com)
              |
              |   (Send file)
              v
     Destination Server 1
   (server1.example.com)
              |
              |   (Send file)
              v
     Destination Server 2
   (server2.example.com)
        /        \
  (Send file) (Send file)
      |             |
      v             v
Destination Server 3  Destination Server 4
(server3.example.com) (server4.example.com)
      |             |
      v             v
  (Send file)   (Send file)
      |             |
      v             v
Destination Server 5  Destination Server 6
(server5.example.com) (server6.example.com)

And here is an example script that implements this:

FILE /tmp/fileExample Script
#!/bin/bash
######################################################
# Script to Send Files Between Multiple FTP Servers  #
######################################################

source_server="source.example.com"
source_username="source_username"
source_password="source_password"
filename="file.txt"

destination_servers=("server1.example.com" "server2.example.com" "server3.example.com" "server4.example.com" "server5.example.com")
destination_username="destination_username"
destination_password="destination_password"
destination_directory="/path/to/destination/directory"

# Send the file from the source server to the five destination servers
for server in "${destination_servers[@]}"
do
    echo "Sending the file to $server"
    
    # Use lftp to connect to the source server and transfer the file to the destination server
    lftp -e "open -u $source_username,$source_password $source_server; put $filename -o $destination_directory/$filename; exit" $server &
done

wait

# Send files between the five destination servers
for ((i=0; i<${#destination_servers[@]}; i++)); do
    for ((j=i+1; j<${#destination_servers[@]}; j++))
    do
        echo "Sending the file from ${destination_servers[$i]} to ${destination_servers[$j]}"
          # Use lftp to connect to the first destination server, retrieve the file, and send it to the second destination server
        lftp -e "open -u $destination_username,$destination_password ${destination_servers[$i]}; get $filename -o - | lftp -e 'open -u $destination_username,$destination_password ${destination_servers[$j]}; put -O $destination_directory/$filename -; exit' -; exit" &
        echo "Sending the file from ${destination_servers[$j]} to ${destination_servers[$i]}"
        
        # Use lftp to connect to the second destination server, retrieve the file, and send it to the first destination server
        lftp -e "open -u $destination_username,$destination_password ${destination_servers[$j]}; get $filename -o - | lftp -e 'open -u $destination_username,$destination_password ${destination_servers[$i]}; put -O $destination_directory/$filename -; exit' -; exit" &
    done
done

wait

echo "All file transfers are completed"

LFTP allows us to interact with an FTP server as if it were our own local system. This gives us the ability to execute commands such as du -sh, which checks the size of a directory. By appending quit to the command, we ensure that LFTP exits after executing the command, thereby emulating a typical shell experience. Once the command has been executed, we automatically disconnect from the FTP server. For instance, to check the size of a directory on an FTP server:

user $lftp -e "open -e 'fxp ftp://source_server.com; get /path/to/source/file' ftp://destination_server.com; quit"

Configuration

user $cat ~/.lftprc
########## SETTINGS 

# On startup, lftp executes ~/.lftprc and ~/.lftp/rc. You can place aliases and 'set' commands 
# there. Some people prefer to see full protocol debug, use 'debug' to turn the debug on.

# Certain commands and settings take a time interval parameter. It has the format Nx[Nx...], where N is time amount
# (floating point) and x is time unit: d - days, h - hours, m - minutes, s - seconds. Default unit is second. E.g.
# 5h30m or 5.5h. Also the interval can be 'infinity', 'inf', 'never', 'forever' - it means infinite interval. E.g.
# 'sleep forever' or 'set dns:cache-expire never'.

# The name of a variable can be abbreviated unless it becomes ambiguous. The prefix before ':' can be omitted too. 
# You can set one variable several times for different closures, and thus you can get a particular settings for 
# particular state. The closure is to be specified after variable name separated with slash '/'.

# The closure for 'dns:', 'net:', 'ftp:', 'http:', 'hftp:' domain variables is currently just the host name as you
# specify it in the 'open' command (with some exceptions where closure is meaningless, e.g. dns:cache-size). For 
# some 'cmd:' domain variables the closure is current URL without path. For other variables it is not currently 
# used. See examples in the sample lftp.conf.

# Boolean settings can be one of (true, on, yes, 1, +) for a True value or one of (false, off, no, 0, -) for a False 
# value.

# There is also a system-wide startup file in /etc/lftp.conf. It can be in different directory, see FILES section.

# lftp has the following settable variables (you can also use 'set -a' to see all variables and their values):
# save plain text passwords in ~/.lftp/bookmarks on 'bookmark add' command. Off by default.
set bmk:save-passwords no

# The commands in string are executed before lftp exits. 
set cmd:at-exit "bye"

# enables csh-like history expansion.
set cmd:csh-history no

#The value is used when 'open' is used with just host name without protocol. Default is 'ftp'.
set cmd:default-protocol ftp

# if true, exit when an unconditional (without || and && at begin) command fails. 
set cmd:fail-exit no

# time of command execution, which is considered as 'long' and a beep is done before next prompt. 0 means off.
set cmd:long-running 1

# default ls argument
set cmd:ls-default "ls -lh"

# when false, lftp refuses to go to background when exiting. To force it, use 'exit bg'.
set cmd:move-background yes

# The prompt. lftp recognizes the following backslash-escaped special characters that are decoded as follows: 
# \@
#  insert @ if current user is not default
# \a
# an ASCII bell character (07)
# \e
# an ASCII escape character (033)
# \h
# the hostname you are connected to
# \n
# newline
# \s
# the name of the client (lftp)
# \S
# current slot name
# \u
# the username of the user you are logged in as
# \U
# the URL of the remote site (e.g., ftp://g437.ub.gu.se/home/james/src/lftp)
# \v
# the version of lftp (e.g., 2.0.3)
# \w
# the current working directory at the remote site
# \W
# the base name of the current working directory at the remote site
# \nnn
# the character corresponding to the octal number nnn
# \\
# a backslash
# \?
# skips next character if previous substitution was empty.
# \[
# begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the 
# prompt
# \]
# end a sequence of non-printing characters 
set cmd:prompt "\\[\\e[1;30m\\][\\[\\e[0;34m\\]f\\[\\e[1m\\]t\\[\\e[37m\\]p\\[\\e[30m\\]] \\[\\e[34m\\]\\u\\[\\e[0;34m\\]\\@\\[\\e[1m\\]\\h\\[\\e[1;30m\\]:\\[\\e[1;34m\\]\\w\\[\\e[1;30m\\]>\\[\\e[0m\\]"

# Number of jobs run in parallel in non-interactive mode. For example, this may be useful for scripts with 
# multiple 'get' commands. Note that setting this to a value greater than 1 changes conditional execution behaviour, 
# basically makes it inconsistent. 
set cmd:parallel 1

# Number of jobs run in parallel in a queue.
set cmd:queue-parallel 1

# This setting is the default value for cls --time-style option.
set cmd:time-style "%b %e %Y|%b %e %H:%M"

# When false, empty listings are not cached.
set cache:cache-empty-listings false

# When false, cache is disabled.
set cache:enable yes

# Positive cache entries expire in this time interval.
set cache:expire 1h

# Negative cache entries expire in this time interval.
set cache:expire-negative 1h

# Maximum cache size. When exceeded, oldest cache entries will be removed from cache.
set cache:size 512

# a boolean to control whether or not lftp uses remote completion.
set cmd:remote-completion yes

# if true, lftp resolves host name immediately in 'open' command. It is also possible to skip the check for a 
# single 'open' command if '&' is given, or if ^Z is pressed during the check. 
set cmd:verify-host yes

# if true, lftp checks the path given in 'cd' command. It is also possible to skip the check for a single 'cd' 
# command if '&' is given, or if ^Z is pressed during the check. Examples: 
set cmd:verify-path no

# When false, 'cd' to a directory known from cache as existent will succeed immediately. Otherwise the
# verification will depend on cmd:verify-path setting.
set cmd:verify-path-cached no

# query for SRV records and use them before gethostbyname. The SRV records are only used if port is not explicitly
# specified. See RFC2052 for details.
set dns:SRV-query no

# enable DNS cache. If it is off, lftp resolves host name each time it reconnects.
set dns:cache-enable yes

# time to live for DNS cache entries. It has format <number><unit>+, e.g. 1d12h30m5s or just 36h. To disable 
# expiration, set it to 'inf' or 'never'.
set dns:cache-expire 1h

# maximum number of DNS cache entries.
set dns:cache-size 512

# limit the time for DNS queries. If DNS server is unavailable too long, lftp will fail to resolve a given host 
# name. Set to 'never' to disable.
set dns:fatal-timeout never

# sets the order of DNS queries. Default is ''inet6 inet'' which means first look up address in inet6 family, then 
# inet and use them in that order. To disable inet6 (AAAA) lookup, set this variable to ''inet''. 
set dns:order "inet6 inet"

# if true, lftp will fork before resolving host address. Default is true.
set dns:use-fork yes

# If zero, there is no limit on the number of times lftp will try to lookup an address. If > 0, lftp will try only 
# this number of times to look up an address of each address family in dns:order. 
set dns:max-retries 1000

# local character set. It is set from current locale initially.
set file:charset utf-8

# the character set used by fish server in requests, replies and file listings. Default is empty which means the
# same as local.
set fish:charset utf-8

# the program to use for connecting to remote server. It should support '-l' option for user name, '-p' for port
# number. Default is 'ssh -a -x'. You can set it to 'rsh', for example.
set fish:connect-program "ssh -a -x"

# use specified shell on server side. Default is /bin/sh. On some systems, /bin/sh exits when doing cd to a 
# non-existent directory. lftp can handle that but it has to reconnect. Set it to /bin/bash for such systems if bash 
# is installed. 
set fish:shell /bin/sh

# Send this string in ACCT command after login. The result is ignored. The closure for this setting has format 
# user@host. 
set ftp:acct "!@!"

# sets the password used for anonymous ftp access authentication. Default is "-name@", where name is the username
# of the user running the program.
set ftp:anon-pass ""

# sets the user name used for anonymous ftp access authentication. Default is "anonymous".
set ftp:anon-user "anonymous"

# if first server message matches this regex, turn on sync mode for that host.
set ftp:auto-sync-mode "Microsoft FTP Service|MadGoat"

# the character set used by ftp server in requests, replies and file listings. Default is empty which means the
# same as local. This setting is only used when the server does not support UTF8.
set ftp:charset "UTF-8"

# the name of ftp client to send with CLNT command, if supported by server. If it is empty, then no CLNT command 
# will be sent. 
set ftp:client fart-ftp.v3

# bind data socket to the interface of control connection (in passive mode). Default is true, exception is the
# loopback interface.
set ftp:bind-data-socket yes

# if true, lftp will try to correct address returned by server for PASV command in case when server address is in 
# public network and PASV returns an address from a private network. In this case lftp would substitute server 
# address instead of the one returned by PASV command, port number would not be changed. Default is true. 
set ftp:fix-pasv-address yes

# if true, lftp will try to set up source ftp server in passive mode first, otherwise destination one. If first 
# attempt fails, lftp tries to set them up the other way. If the other disposition fails too, lftp falls back to 
# plain copy. See also ftp:use-fxp. 
set ftp:fxp-passive-source yes

# initial directory. Default is empty string which means auto. Set this to '/' if you don't like the look of %2F 
# in ftp URLs. The closure for this setting has format user@host. 
set ftp:home "/"

# If true, lftp uses control connection address instead of the one returned in PASV reply for data connection. 
# This can be useful for broken NATs. Default is false. 
set ftp:ignore-pasv-address yes
 
# if set to false, empty lists from LIST command will be treated as incorrect, and another method (NLST) will be used. 
set ftp:list-empty-ok yes

# sets options which are always appended to LIST command. It can be useful to set this to '-a' if server does not 
# show dot (hidden) files by default. Default is empty. 
set ftp:list-options  "-a"

# delay between NOOP commands when downloading tail of a file. This is useful for ftp servers which send "Transfer 
# complete" message before flushing data transfer. In such cases NOOP commands can prevent connection timeout. 
set ftp:nop-interval 60

# sets passive ftp mode. This can be useful if you are behind a firewall or a dumb masquerading router. In passive
# mode lftp uses PASV command, not the PORT command which is used in active mode. In passive mode lftp itself makes
# the data connection to the server; in active mode the server connects to lftp for data transfer. Passive mode is 
# the default.
set ftp:passive-mode yes

# specifies an IPv4 address to send with PORT command. Default is empty which means to send the address of local 
# end of control connection. 
set ftp:port-ipv4 <your-ip>

# allowed port range for active mode. Format is min-max, or 'full' or 'any' to indicate any port. Default is 'full'.
set ftp:port-range <start-end>

# specifies ftp proxy to use. To disable proxy set this to empty string. Note that it is an ftp proxy which uses 
# ftp protocol, not ftp over http. Default value is taken from environment variable ftp_proxy if it starts with 
# ''ftp://''. If your ftp proxy requires authentication, specify user name and password in the URL. If ftp:proxy 
# starts with http:// then hftp protocol (ftp over http proxy) is used instead of ftp automatically. 
# set ftp:proxy (URL)

# When set to ''joined'', lftp sends ''user@proxy_user@ftp.example.org'' as user name to proxy, and 
# ''password@proxy_password'' as password. 
#  When set to ''joined-acct'', lftp sends ''user@ftp.example.org proxy_user'' as user name to proxy. The site 
# password is sent as usual and the proxy password is expected in the following ACCT command.
# When set to ''open'', lftp first sends proxy user and proxy password and then ''OPEN ftp.example.org'' followed 
# by ''USER user''. The site password is then sent as usual.
# When set to ''user'' (default), lftp first sends proxy user and proxy password and then 
# ''user@ftp.example.org'' as user name. The site password is then sent as usual. 
# set ftp:proxy-auth-type (string)

# allow usage of REST command before LIST command. This might be useful for large directories, but some ftp 
# servers silently ignore REST before LIST. 
set ftp:rest-list yes

# if false, lftp will not try to use REST before STOR. This can be useful for some buggy servers which corrupt 
# (fill with zeros) the file if REST followed by STOR is used. 
set ftp:rest-stor yes

# Retry on server reply 530 for PASS command if text matches this regular expression. This setting should be 
# useful to distinguish between overloaded server (temporary condition) and incorrect password (permanent condition). 
set ftp:retry-530 "too many|overloaded|try (again |back )?later|is restricted to|maximum number|number of connect|only.*session.*allowed|more connection|already connected"

# Additional regular expression for anonymous login, like ftp:retry-530. 
set ftp:retry-530-anonymous "Login incorrect"

# Send this string in SITE GROUP command after login. The result is ignored. The closure for this setting has 
# format user@host. 
# set ftp:site-group "user@host"

# allow sending skey/opie reply if server appears to support it. On by default. 
set ftp:skey-allow yes

# do not send plain text password over the network, use skey/opie instead. If skey/opie is not available, assume 
# failed login. Off by default. 
set ftp:skey-force no

# if true, try to negotiate SSL connection with ftp server for non-anonymous access. Default is true. This and 
# other ssl settings are only available if lftp was compiled with an ssl/tls library. 
set ftp:ssl-allow yes

# if true, lftp loads ssl:key-file for protected data connection too. When false, it does not, and the server can 
# match data and control connections by session ID. Default is true. 
# if true, refuse to send password in clear when server does not support SSL. Default is false.
set ftp:ssl-force yes

# if true, request ssl connection for data transfers. This is cpu-intensive but provides privacy. Default is false.
set ftp:ssl-protect-data yes

# if true, request ssl connection for data transfer between two ftp servers in FXP mode. CPSV or SSCN command will 
# be used in that case. If ssl connection fails for some reason, lftp would try unprotected FXP transfer unless 
# ftp:ssl-force is set for any of the two servers. Default is false. 
set ftp:ssl-protect-fxp yes

# if true, request ssl connection for file list transfers. Default is true.
set ftp:ssl-protect-list yes

# if true, lftp would issue CCC command after logon, thus disable ssl protection layer on control connection.
set ftp:ssl-use-ccc no

# interval between STAT commands. Default is 1 second.
set ftp:stat-interval 1

# if true, lftp will send one command at a time and wait for response. This might be useful if you are using a 
# buggy ftp server or router. When it is off, lftp sends a pack of commands and waits for responses - it speeds up 
# operation when round trip time is significant. Unfortunately it does not work with all ftp servers and some 
# routers have troubles with it, so it is on by default. 
set ftp:sync-mode yes

# Assume this timezone for time in listings returned by LIST command. This setting can be GMT offset 
# [+|-]HH[:MM[:SS]] or any valid TZ value (e.g. Europe/Moscow or MSK-3MSD,M3.5.0,M10.5.0/3). The default is GMT. Set 
# it to an empty value to assume local timezone specified by environment variable TZ. 
set ftp:timezone "EDT"

# if false, lftp does not send ABOR command but closes data connection immediately.
set ftp:use-abor yes

# when true (default), lftp sends ALLO command before uploading a file.
set ftp:use-allo yes

# when true (default), lftp uses FEAT command to determine extended features of ftp server.
set ftp:use-feat true

# if true, lftp will try to set up direct connection between two ftp servers.
set ftp:use-fxp no

# when ftp:proxy points to an http proxy, this setting selects hftp method (GET, HEAD) when true, and CONNECT 
# method when false. Default is true. 
set ftp:use-hftp no

# the language selected with LANG command, if supported as indicated by FEAT response. Default is empty which
# means server default.
set ftp:lang true

# when true (default), lftp uses MDTM command to determine file modification time.
set ftp:use-mdtm no

# when true, lftp uses two argument MDTM command to set file modification time on uploaded files. Default is false.
set ftp:use-mdtm-overloaded no

# when true, lftp sends 'SITE IDLE' command with net:idle argument. Default is false.
set ftp:use-site-idle no

# when true, lftp sends 'SITE UTIME' command to set file modification time on uploaded files. Default is true.
set ftp:use-site-utime yes

# when  true, lftp sends 2-argument `SITE UTIME' command to set file modification time on uploaded files.  
# Default  is  true.   If  5-argument  `SITE UTIME' is also enabled, 2-argument command is tried first.
set ftp:use-site-utime2 yes

# when true (default), lftp uses SIZE command to determine file size.
set ftp:use-size yes

# if true, lftp sends STAT command in FXP mode transfer to know how much data has been transferred. See also 
# ftp:stat-interval. Default is true.
set ftp:use-stat yes

# when true, lftp uses STAT instead of LIST command. By default '.' is used as STAT argument. Using STAT, lftp 
# avoids creating data connection for directory listing. Some servers require special options for STAT, use 
# ftp:list-options to specify them (e.g. -la). 
set ftp:use-stat-for-list yes

# when true (default), lftp uses TELNET IAC command and follows TELNET protocol as specified in RFC959. When 
# false, it does not follow TELNET protocol and thus does not double 255 (0xFF, 0377) character and does not prefix 
# ABOR and STAT commands with TELNET IP+SYNCH signal. 
set ftp:use-telnet-iac no

# if true, lftp sends QUIT before disconnecting from ftp server. Default is true. 
set ftp:use-quit yes

# verify that data connection comes from the network address of control connection peer. This can possibly prevent 
# data connection spoofing which can lead to data corruption. Unfortunately, this can fail for certain ftp servers 
# with several network interfaces, when they do not set outgoing address on data socket, so it is disabled by 
# default. 
set ftp:verify-address yes

# verify that data connection has port 20 (ftp-data) on its remote end. This can possibly prevent data connection 
# spoofing by users of remote host. Unfortunately, too many windows and even unix ftp servers forget to set proper 
# port on data connection, thus this check is off by default. 
set ftp:verify-port yes

# disconnect after closing data connection. This can be useful for totally broken ftp servers. Default is false.
set ftp:web-mode no

# specifies initial PROT setting for FTPS connections. Should be one of: C, S, E, P, or empty. Default is empty 
# which means unknown, so that lftp will use PROT command unconditionally. If PROT command turns out to be 
# unsupported, then Clear mode would be assumed. 
set ftps:initial-prot "E"

# allow server/proxy side caching for ftp-over-http protocol. 
set hftp:cache no

# specify corresponding HTTP request header.
# hftp:cache-control (string)

# specifies http proxy for ftp-over-http protocol (hftp). The protocol hftp cannot work without a http proxy, 
# obviously. Default value is taken from environment variable ftp_proxy if it starts with ''http://'', otherwise 
# from environment variable http_proxy. If your ftp proxy requires authentication, specify user name and password in the URL. 
# hftp:proxy (URL)

# if set to off, lftp will send password as part of URL to the proxy. This may be required for some proxies (e.g. 
# M-soft). Default is on, and lftp will send password as part of Authorization header. 
# set hftp:use-authorization (boolean)

# if set to off, lftp will try to use 'GET' instead of 'HEAD' for hftp protocol. While this is slower, it may 
# allow lftp to work with some proxies which don't understand or mishandle ''HEAD ftp://'' requests. 
# set hftp:use-head (boolean)

# if set to off, lftp will try to use 'PUT' instead of 'MKCOL' to create directories with hftp protocol. Default
# is off.
# set hftp:use-mkcol (boolean)

# if set to off, lftp will not try to use 'PROPFIND' to get directory contents with hftp protocol and use 'GET'
# instead. Default is off.
# set hftp:use-propfind (boolean)

# If set to off, lftp won't try to append ';type=' to URLs passed to proxy. Some broken proxies don't handle it 
# correctly. Default is on. 
# http:accept, http:accept-charset, http:accept-language (string)
# specify corresponding HTTP request headers. 
# set hftp:use-type (boolean)

# the authorization to use by default, when no user is specified. The format is ''user:password''. Default is
# empty which means no authorization.
set http:authorization "user:password"

# allow server/proxy side caching.
set http:cache no

# specify corresponding HTTP request header.
set http:cache-control ""

# send this cookie to server. A closure is useful here: set cookie/www.somehost.com "param=value" 
# http:post-content-type (string)
# specifies value of Content-Type http request header for POST method. Default is 
# ''application/x-www-form-urlencoded''. 
# set http:cookie (string)

# specifies http proxy. It is used when lftp works over http protocol. Default value is taken from environment 
# variable http_proxy. If your proxy requires authentication, specify user name and password in the URL. 
# set http:proxy (URL)

# specifies which http method to use on put.
# set http:put-method (PUT or POST)

# specifies value of Content-Type http request header for PUT method. 
# set http:put-content-type (string)

#     specifies value for Referer http request header. Single dot '.' expands to current directory URL. Default is 
# '.'. Set to empty string to disable Referer header. 
set http:referer "."

# if true, lftp modifies http:cookie variables when Set-Cookie header is received. 
set http:set-cookie no

# if set to off, lftp will try to use 'PUT' instead of 'MKCOL' to create directories with http protocol. Default is on. 
set http:use-mkcol on

# if set to off, lftp will not try to use 'PROPFIND' to get directory contents with http protocol and use 'GET' 
# instead. Default is on. 
set http:use-propfind on

# the string lftp sends in User-Agent header of HTTP request. 
set http:user-agent "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"

# specifies https proxy. Default value is taken from environment variable https_proxy. 
# set https:proxy 

# when true, mirror will dereference symbolic links by default. You can override it by --no-dereference option. 
# Default if false. 
# set mirror:dereference (boolean)

# specifies default exclusion pattern. You can override it by --include option. 
# set mirror:exclude-regex (regex)

# specifies default inclusion pattern. It is used just after mirror:exclude-regex is applied. It is never used if mirror:exclude-regex is empty.
# set mirror:include-regex (regex) 

# set mirror:order (list of patterns)
# specifies order of file transfers. E.g. setting this to "*.sfv *.sum" makes mirror to transfer files matching 
# *.sfv first, then ones matching *.sum and then all other files. To process directories after other files, add "*/" 
# to end of pattern list. 

# if true, mirror will start processing of several directories in parallel when it is in parallel mode. Otherwise, 
# it will transfer files from a single directory before moving to other directories. 
# set mirror:parallel-directories (boolean)

# specifies number of parallel transfers mirror is allowed to start. Default is 1. You can override it with 
# --parallel option. 
# set mirror:parallel-transfer-count (number)

# When set to off, mirror won't try to copy file and directory permissions. You can override it by --perms option. 
# Default is on. 
# set mirror:set-permissions (boolean)

# specifies -n option for pget command used to transfer every single file under mirror. Default is 1 which disables pget. 
set mirror:use-pget-n 0

# colon separated list of directories to look for modules. Can be initialized by environment variable 
# LFTP_MODULE_PATH. Default is 'PKGLIBDIR/VERSION:PKGLIBDIR'. 
# set module:path (string)

# maximum number of concurrent connections to the same site. 0 means unlimited.
set net:connection-limit 2

# if true, foreground connections have priority over background ones and can interrupt background transfers to 
# complete a foreground operation. 
set net:connection-takeover yes

# disconnect from server after this idle time. Default is 3 minutes. Setting is in seconds. 
# set net:idle 500 # let the server deal with idle time

# limit transfer rate on data connection. 0 means unlimited. You can specify two numbers separated by colon to 
# limit download and upload rate separately. 
set net:limit-rate 0

# limit accumulating of unused limit-rate. 0 means unlimited.
set net:limit-max 0

# limit transfer rate of all connections in sum. 0 means unlimited. You can specify two numbers separated by colon 
# to limit download and upload rate separately. Note that sockets have receive buffers on them, this can lead to 
# network link load higher than this rate limit just after transfer beginning. You can try to set net:socket-buffer to 
# relatively small value to avoid this. 
set net:limit-total-rate 0

# limit accumulating of unused limit-total-rate. 0 means unlimited.
set net:limit-total-max 0

# the maximum number of sequential retries of an operation without success. 0 means unlimited. 
set net:max-retries 10

# contains comma separated list of domains for which proxy should not be used. Default is taken from environment 
# variable no_proxy. 
# set net:no-proxy (string)

# ignore this number of hard errors. Useful to login to buggy ftp servers which reply 5xx when there is too many users. 
set net:persist-retries 5

# sets the base minimal time between reconnects. Actual interval depends on net:reconnect-interval-multiplier and 
# number of attempts to perform an operation. 
set net:reconnect-interval-base 60

# sets maximum reconnect interval. When current interval after multiplication by net:reconnect-interval-multiplier 
# reachs this value (or exceeds it), it is reset back to net:reconnect-interval-base. 
set net:reconnect-interval-max 60

# sets multiplier by which base interval is multiplied each time new attempt to perform an operation fails. When 
# the interval reachs maximum, it is reset to base value. See net:reconnect-interval-base and 
# net:reconnect-interval-max. 
# set net:reconnect-interval-multiplier (real number)

# bind all IPv4 sockets to specified address. This can be useful to select a specific network interface to use. 
# Default is empty which means not to bind IPv4 sockets, operating system will choose an address automatically using 
# routing table. 
set net:socket-bind-ipv4 192.168.76.150

# the same for IPv6 sockets.
# set net:socket-bind-ipv6 (ipv6 address)

# use given size for SO_SNDBUF and SO_RCVBUF socket options. 0 means system default.
set net:socket-buffer 0

# use given size for TCP_MAXSEG socket option. Not all operating systems support this option, but linux does
set net:socket-maxseg 0

#  sets the network protocol timeout.
set net:timeout 5

# default number of chunks to split the file to in pget.
# set pget:default-n (number)

# save pget transfer status this often. Set to 'never' to disable saving of the status file. The status is saved 
# to a file with suffix .lftp-pget-status. 
# pget:save-status (time interval)

# the character set used by sftp server in file names and file listings. Default is empty which means the same as 
# local. This setting is only used for sftp protocol version prior to 4. Version 4 and later always use UTF-8. 
set sftp:charset "utf-8"

# set program to use for connecting to remote server. It should support '-l' option for user name, '-p' for port 
# number. Default is 'ssh -a -x'. You can set it to 'rsh', for example. 
set sftp:connect-program "ssh -a -x"

# The maximum number of unreplied packets in flight. If round trip time is significant, you should increase this 
# and size-read/size-write. Default is 16. 
set sftp:max-packets-in-flight 16

# The protocol number to negotiate. Default is 4. The actual protocol version used depends on server.
set sftp:protocol-version 2

# The server program implementing SFTP protocol. If it does not contain a slash '/', it is considered a ssh2 
# subsystem and -s option is used when starting connect-program. Default is 'sftp'. You can use rsh as transport 
# level protocol like this: 
set sftp:server-program "/usr/lib64/misc/sftp-server"

#   set sftp:connect-program rsh
#   set sftp:server-program /usr/libexec/openssh/sftp-server
#    Similarly you can run sftp over ssh1. 

# Block size for reading. Default is 0x8000.
set sftp:size-read  0x8000

# Block size for writing. Default is 0x8000.
set sftp:size-write 0x8000

# use specified file as Certificate Authority certificate.
# set ssl:ca-file (path to file)

# when true, lftp checks if the host name used to connect to the server corresponds to the host name in its 
# certificate. 
set ssl:check-hostname yes

# set ssl:ca-path (path to directory)
# use specified directory as Certificate Authority certificate repository. 
#set ssl:ca-path "/etc/ssl/certs/"

# use specified file as Certificate Revocation List certificate.
# set ssl:crl-file (path to file)

# use specified directory as Certificate Revocation List certificate repository.
# set ssl:crl-path (path to directory)

# set specified file as your private key.
# set ssl:key-file (path to file)

# use specified file as your certificate.
# set ssl:cert-file (path to file)

# if set to yes, then verify server's certificate to be signed by a known Certificate Authority and not be on
# Certificate Revocation List.
set ssl:verify-certificate no

# if this setting is off, get commands will not overwrite existing files and generate an error instead. Default is on.
set xfer:clobber on

# This setting is used as default -O option for get and mget commands. Default is empty, which means current 
# directory (no -O option). 
set xfer:destination-directory "/home/user/path/to/your/stuff"

# the period over which weighted average rate is calculated to produce ETA.
set xfer:eta-period 3

# show terse ETA (only high order parts). Default is true.
set xfer:eta-terse yes

# when true, lftp logs transfers to ~/.lftp/transfer_log.
set xfer:log yes

# maximum number of redirections. This can be useful for downloading over HTTP. 0 prohibits redirections.
set xfer:max-redirections 0

# the period over which weighted average rate is calculated to be shown.
set xfer:rate-period 3

HTTP/HTTPS

While tools like curl and httpie are often the go-to choices for making HTTP/HTTPS POST and GET requests, it's worth noting that lftp can be equally capable and powerful for various tasks. Below is an example demonstrating how to perform a POST request to retrieve the "backup_jffs.tar" file from an Asus Router using lftp:

lftp <<EOF
open http://192.168.50.1
quote set-cookie "asus_token=<session>t; clickedItem_tab=3"
set http:referer "http://192.168.50.1/Advanced_SettingBackup_Content.asp"
set http:use-compress true
set ssl:verify-certificate no
get /backup_jffs.tar -o backup_jffs.tar
EOF

In this script, lftp establishes a connection to "http://192.168.50.1", sets specific HTTP headers, and retrieves the "backup_jffs.tar" file, saving it as "backup_jffs.tar".

Tor SOCKS proxy

Open the Tor configuration file (/etc/tor/torrc on Linux) and make sure the following lines are present:

FILE /etc/tor/torrcConfigure Tor SOCKS proxy
SocksPort 9050
SocksPolicy accept *

Start lftp with Tor: Use the following command to start lftp and configure it to use Tor's SOCKS proxy:

user $lftp -e "set ftp:proxy socks://localhost:9050; open ftp://username:password@ftpserver"
Note
If there is a specific Tor control port configured, the user can incorporate the --tor-ctrl-port option into the command, providing the appropriate control port number.