Let's see how passive mode works with a real-time download.
Let's jump right into the client and review the FTP
passive mode download script.
The script is identical to the FTP active mode download script with
one small change: We set passive mode to yes,
which is the default for lftp,
but I explicitly enable it here for learning purposes.
Let's run the script and see what happens.
The initial feature and login conversations haven't
changed at all from FTP active mode.
I do want to point out the feature response of PASV from the server.
If the server didn't tell the client that it supported passive mode,
the client would be forced to operate in active mode,
regardless of our script settings.
After some other administrative commands,
the client issues the almighty PASV message.
It's a pretty boring one, as it contains no interesting data or arguments.
The reply from the server is more like the FTP active mode PORT command,
as it contains the server's IP address and the dynamic port
upon which the client should connect.
Lftp debugging tells us the port number is 9106.
The client connects to the server,
issues the retrieve command to download R1.cfg,
then closes the FTP data session once the transfer is complete.
Then, just for fun,
I'm showing the directory listing on the server side to demonstrate that
commands other than file transfers are supported with passive mode.
Let's quickly check to ensure R1.cfg is present. This looks good and passive mode downloads appear to be working just fine.