FTP and FTPS use multiple connections to perform file transfers. In passive mode (a.k.a. PASV), both control and data connections are made from the FTP client to the FTP server.
FTP may run in active or passive mode, which determines how the data connection is established.
In both cases, the client creates a TCP control connection from a random unprivileged port N to the FTP server command port 21. In active modes, the client starts listening for incoming data connections on port N+1 from the server (the client sends the FTP command PORT
or EPRT
to inform the server on which port it is listening).
In situations where the client is behind a firewall and unable to accept incoming TCP connections, passive mode may be used.
In this mode, the client uses the control connection to send a PASV
or EPSV
command to the server and then receives a server server port number from the server, which the client then uses to open a data connection from an arbitrary client port to the server IP address and server port number received.