Active vs Passive FTP
FTP stands for File Transfer Protocol. It is a standard protocol, which is used in file transferring from one host to another host over a TCP based network. FTP has client-server architecture, and it operates on OSI model of the application layer. There are four data representation modes when transferring data over a network,
1. ASCII mode
2. Binary mode (image mode)
3. EBCDIC mode
4. Local mode
When one host (let’s say host A) needs to transfer a file to another host (let’s say host B), there should be a connection between this host A and host B. There are two ways to make this connection between two hosts. They are called,
1. Active FTP
2. Passive FTP
(Actually, these are not different types of FTP, but different ways of FTP port opening.)
In active mode, the FTP client connects to the FTP server’s port 21 from a random unprivileged port, which is usually greater than 1024 (port number). Following is the way of communicating between FTP client and FTP server in Active FTP,
• Client’s command port contacts the server’s command port and gives its data port.
• Server gives an acknowledgement to the client’s command port.
• Server establishes a connection between its data port and client’s data port.
• At last, client sends an acknowledgement to the server.
Active FTP should be used when the FTP server, which is trying to connect, does not support passive FTP connections, or if the FTP server is behind a firewall/router/NAT device.
Passive FTP mode is developed to solve the connection issues of the Active mode. FTP client can use PASV command to tell the server, the connection is passive. This is the communication between FTP client and the server in passive mode.
• Client contacts the servers command port and issue PASV command to tell this is passive connection.
• Then the server gives its listening data port to the client.
• Then the client makes a data connection between server and itself using the given port. (port is given by the server)
• At last, server sends an acknowledgement to the client.
Passive FTP should be used all the time unless an error occurred or if the FTP connection is using non standard FTP ports.
What is the difference between Active and Passive FTP?
1. Active mode provides more security to the FTP server. But in passive mode it does not. (Passive mode is used when the FTP connections are blocked by the firewalls.)
2. Active FTP may cause problems because of firewalls. But Passive FTP does not have connection issues from firewalls)
3. In active mode, client establishes the command channel and the server establishes the data channel, but in passive FTP, both the connections are established by the client.
4. Most of the web browser’s default mode is Passive. Active mode is not used as a default mode of a browser.