Commands / Services and tunnels

Services and tunnels

lftp

Also ftp client, FTP, passive mode, active mode

An FTP client: logs in, lists, downloads and uploads, and with -d shows every command and reply.

lftp -u USER,PASSWORD HOST opens an FTP session; -e '…' runs lftp commands (ls, get, put, cat, quit) and -d prints the control channel as it goes: ---> what lftp sends, <--- the server's replies, and ---- its own notes, such as which port it opens the data connection to. set ftp:passive-mode off switches to active mode; set ftp:prefer-epsv off makes it ask with the classic PASV, whose reply shows the address.

lftp command usage

lftp -u USER,PASSWORD HOST
lftp [-d] -u USER,PASSWORD -e 'COMMANDS; quit' HOST

Options

-u alice,s3cret
user and password
-d
debug: show every FTP command and reply
-e 'cat notes.txt; quit'
run these lftp commands, then stop
set ftp:passive-mode off
active mode: the server connects back
set ftp:prefer-epsv off
PASV rather than EPSV

lftp examples

lftp -u alice,s3cret fileServer.lab
Opens an interactive FTP session as alice.
lftp -d -u alice,s3cret -e 'set ftp:prefer-epsv off; cat notes.txt; quit' fileServer.lab
Prints notes.txt in passive mode, showing the PASV exchange and the data connection.

Pitfalls

  • lftp tries AUTH TLS first; a server without TLS answers 530, and lftp goes on in the clear. set ftp:ssl-allow off skips the attempt.

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start free