Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 4
    What? The data connection does not use port 20; it uses a random port >1024. Also ftp does not appear to have a -P option, at least not on Ubuntu 16.04. Thus you can not forward ftp with ssh since you don't know what random port will be chosen when the data connection is established ( and you get a different one for each file transferred or each time you ls ). Commented Mar 15, 2018 at 17:40
  • Nope, the server listens on an ephemeral port as well. It has to since it can be serving multiple clients and if it used port 20 for each of them, it would have no idea which one corresponded to which control session. Commented Mar 15, 2018 at 17:58
  • I printed out the FTP RFC on my dot matrix printer and studied it when I was 16. I figured out that you can issue a PASV command to one server, then a PORT command to the other server with the IP address and port number from the PASV response from the other server and get them to send the file directly from one server to the other instead of having to download and upload it myself over my 28.8kbps modem. Later a program called FXP came out that could do that, and I also wrote my own FTP server software for WinNT that blew the pants off of anything else. Go look at a PASV reply yourself. Commented Mar 15, 2018 at 18:02
  • You are confused. It listens on port 21, not 20. You connect to the server on port 21, then either issue a PORT command, telling the server what IP and port number it should connect to, or a PASV command, in which case it starts listening for the data connection on an ephemeral port, and specifies which port that is in the reply. From a quote pasv command to ftp.gnu.org: "227 Entering Passive Mode (208,118,235,20,96,222)". Note that the server is listening on port 96,222, or 24,798. Commented Mar 15, 2018 at 18:11
  • 2
    Why not edit it so that it is correct? Commented Mar 22, 2018 at 0:03