What is FTP (File Transfer Protocol)?
Learn what FTP is, how control and data connections work, active vs passive mode, and why SFTP/FTPS replace it for security.
Expected Interview Answer
FTP (File Transfer Protocol) is an application-layer protocol for transferring files between a client and a server over a network, using a separate control connection (port 21) for commands and a distinct data connection for the actual file bytes.
A client opens a TCP control connection to the server on port 21 and authenticates with a username and password (or anonymously). Once authenticated, every file operation such as listing a directory, uploading, or downloading opens a second, separate data connection, either in active mode (server connects back to the client) or passive mode (client connects to a server-provided port), which is friendlier to firewalls and NAT. Plain FTP sends credentials and data unencrypted, which is why FTPS (FTP over TLS) or SFTP is preferred whenever security matters. FTP still shows up in legacy systems, internal file distribution, and some hosting workflows.
- Separates control commands from data transfer on distinct connections
- Supports both active and passive connection modes
- Handles directory listing, upload, download, and resume operations
- Widely supported by legacy tooling and hosting platforms
AI Mentor Explanation
FTP is like a scorerβs booth that keeps a dedicated phone line open with the ground announcer purely for instructions, while a separate runner physically carries the scorecards back and forth between venues. The phone line (control connection) never carries the actual paper, it only says fetch this file or send that one. The runner (data connection) is opened fresh for each handoff, and if gates are locked the runner can be told which gate to use instead, exactly like passive mode gives the client a specific port to connect through.
Step-by-Step Explanation
Step 1
Control connection
The client opens a TCP connection to the server on port 21 and authenticates.
Step 2
Command exchange
The client sends commands like LIST, RETR, or STOR over the control connection.
Step 3
Data connection
A separate connection is opened (active or passive mode) to carry the actual file bytes.
Step 4
Transfer completes
The data connection closes once the file transfer finishes; the control connection can issue more commands.
What Interviewer Expects
- Knows FTP uses separate control (port 21) and data connections
- Can explain active vs passive mode and why passive is firewall-friendly
- Understands plain FTP is unencrypted
- Can name FTPS/SFTP as secure alternatives
Common Mistakes
- Confusing FTP with SFTP, assuming they use the same port or security model
- Thinking FTP uses a single connection for both commands and data
- Not knowing plain FTP transmits credentials in cleartext
- Mixing up active mode (server connects to client) and passive mode (client connects to server)
Best Answer (HR Friendly)
βFTP is one of the oldest ways to move files between two computers over a network β think of it as a dedicated phone line for giving instructions, plus a separate delivery truck for the actual files. It still gets used for legacy systems and simple file distribution, but because it does not encrypt anything by default, most teams today use its secure cousins like SFTP or FTPS instead.β
Code Example
# Connect to an FTP server
ftp ftp.example.com
# Inside the FTP prompt:
# Name: myuser
# Password: ********
ftp> ls
ftp> get report.csv
ftp> put upload.txt
ftp> bye
# Passive-mode transfer with curl instead
curl -u myuser:mypass --ftp-pasv ftp://ftp.example.com/report.csv -o report.csvFollow-up Questions
- What is the difference between active and passive FTP mode?
- Why is plain FTP considered insecure, and what replaces it?
- What port does the FTP control connection use, and how does the data port differ?
- How does FTP behave differently through a NAT or firewall in each mode?
MCQ Practice
1. Which port does the FTP control connection use by default?
FTP control connections use port 21; port 20 is traditionally used for active-mode data transfer.
2. Why is passive FTP mode generally preferred behind NAT or a firewall?
In passive mode the client, not the server, initiates the data connection, avoiding inbound-connection blocks.
3. What is a key weakness of plain FTP?
Plain FTP sends usernames, passwords, and file contents in cleartext, unlike FTPS or SFTP.
Flash Cards
What is FTP? β An application-layer protocol for transferring files using separate control and data connections.
FTP control port? β Port 21, used for authentication and commands.
Active vs passive mode? β Active: server connects to client for data; passive: client connects to server, better for NAT/firewalls.
Is plain FTP secure? β No β it is unencrypted; FTPS or SFTP should be used for secure transfers.