Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between active and passive FTP?

Tags:

networking

ftp

Can someone tell me what is the difference between active and passive FTP?
Which one is preferable?

like image 472
karthik Avatar asked Nov 09 '09 04:11

karthik


People also ask

Should I use passive FTP mode?

This method of FTP is insecure, as a random unprivileged port is opened on the Server. This is a potential security issue and it isn't advisable to use the Passive mode of FTP.

What is the benefit of passive FTP?

The passive mode of FTP was created to alleviate some of the responsibility for firewall configuration from the client-side. In comparison to active FTP, in passive FTP the client initiates both the control and the data channels.

What does use passive FTP mean?

PASV FTP, also called passive FTP, is an alternative mode for establishing File Transfer Protocol (FTP) connections. In short, it solves the problem of an FTP client's firewall blocking incoming connections. "PASV" is the name of the command that the FTP client uses to explain to the server that it's in passive mode.

What are the two FTP modes?

The simplest explanation is that active and passive are the two modes that FTP can run in. An FTP server can be placed in two different default modes by an administrator: Active or Passive. Active mode was originally the only method of FTP, and is therefore often the default mode for FTP.


2 Answers

Active and passive are the two modes that FTP can run in.

For background, FTP actually uses two channels between client and server, the command and data channels, which are actually separate TCP connections.

The command channel is for commands and responses while the data channel is for actually transferring files.

This separation of command information and data into separate channels a nifty way of being able to send commands to the server without having to wait for the current data transfer to finish. As per the RFC, this is only mandated for a subset of commands, such as quitting, aborting the current transfer, and getting the status.


In active mode, the client establishes the command channel but the server is responsible for establishing the data channel. This can actually be a problem if, for example, the client machine is protected by firewalls and will not allow unauthorised session requests from external parties.

In passive mode, the client establishes both channels. We already know it establishes the command channel in active mode and it does the same here.

However, it then requests the server (on the command channel) to start listening on a port (at the servers discretion) rather than trying to establish a connection back to the client.

As part of this, the server also returns to the client the port number it has selected to listen on, so that the client knows how to connect to it.

Once the client knows that, it can then successfully create the data channel and continue.

More details are available in the RFC: https://www.ietf.org/rfc/rfc959.txt

like image 105
paxdiablo Avatar answered Oct 14 '22 03:10

paxdiablo


I recently run into this question in my work place so I think I should say something more here. I will use image to explain how the FTP works as an additional source for previous answer.

Active mode:

active mode


Passive mode:

enter image description here


In an active mode configuration, the server will attempt to connect to a random client-side port. So chances are, that port wouldn't be one of those predefined ports. As a result, an attempt to connect to it will be blocked by the firewall and no connection will be established.

enter image description here


A passive configuration will not have this problem since the client will be the one initiating the connection. Of course, it's possible for the server side to have a firewall too. However, since the server is expected to receive a greater number of connection requests compared to a client, then it would be but logical for the server admin to adapt to the situation and open up a selection of ports to satisfy passive mode configurations.

So it would be best for you to configure server to support passive mode FTP. However, passive mode would make your system vulnerable to attacks because clients are supposed to connect to random server ports. Thus, to support this mode, not only should your server have to have multiple ports available, your firewall should also allow connections to all those ports to pass through!

To mitigate the risks, a good solution would be to specify a range of ports on your server and then to allow only that range of ports on your firewall.

For more information, please read the official document.

like image 30
Yuantao Avatar answered Oct 14 '22 03:10

Yuantao