FTP, the File Transfer Protocol, is a client-server application-layer protocol that transfers files between hosts over TCP, using one connection for commands and a separate connection for data. Among Internet protocols it is one of the oldest still in service: its current form is defined in RFC 959 from 1985, and its design predates the web, TLS and most of the security assumptions that later Internet protocols take for granted.
FTP remains relevant because it is simple, universally supported by servers, embedded devices and legacy business systems, and efficient for bulk transfer. Its weaknesses are equally well known: credentials and data travel in plain text unless the session is wrapped in TLS, and its two-connection model complicates firewalls and NAT.
How FTP separates control and data
FTP works by opening a control connection to the server, normally on TCP port 21, and then opening a new data connection for each file transfer or directory listing. The control channel carries short text commands and three-digit replies for the whole session, while the data channel exists only for the duration of one transfer and closes when it ends.
Commands are plain ASCII lines such as USER, PASS, CWD, LIST, RETR and STOR. Replies begin with a numeric code whose first digit signals the outcome, which makes the protocol easy to script and to debug with a raw terminal session. This out-of-band control design lets a client abort a transfer or query status while data is still flowing.
The following table summarizes the most common commands and what each one does in a typical session.
| Command | Purpose | Typical reply on success |
|---|---|---|
| USER / PASS | Send user name and password | 331, then 230 logged in |
| CWD / PWD | Change or print working directory | 250 or 257 |
| LIST / NLST | Return directory listing over data channel | 150, then 226 |
| RETR | Download a file from the server | 150, then 226 |
| STOR | Upload a file to the server | 150, then 226 |
| PASV / EPSV | Ask the server to open a data port | 227 or 229 |
| TYPE | Select ASCII or binary (image) mode | 200 |
| QUIT | End the session | 221 |
Active mode, passive mode and firewalls
The direction in which the data connection is opened defines the FTP transfer mode. In active mode, the client announces an address and port with the PORT command and the server connects back to the client from port 20. In passive mode, the client sends PASV or EPSV, the server replies with a port it is listening on, and the client opens the data connection itself.
Active mode breaks easily behind client-side NAT and stateful firewalls, because an inbound connection to the client is unexpected. Passive mode moves the problem to the server, which must allow a defined range of high ports. Many firewalls include an FTP application-layer gateway that reads the control channel and opens the matching data port, but that inspection fails once the control channel is encrypted.
| Mode | Who opens the data connection | Firewall impact | Typical use |
|---|---|---|---|
| Active (PORT) | Server connects to client | Blocked by most client NAT | Legacy LAN transfers |
| Passive (PASV) | Client connects to server | Server must open a port range | Default for modern clients |
| Extended passive (EPSV) | Client connects to server | Port only, works with IPv6 | IPv6 and NAT-heavy networks |
| Extended active (EPRT) | Server connects to client | Same issues as active mode | Rare, IPv6 active transfers |
In practice, administrators configure a fixed passive port range, for example 50000 to 51000, and publish the external IP address the server must advertise. A wrong advertised address is the most frequent cause of clients that log in successfully but hang on the first directory listing.
Transfer types, structures and resume
FTP distinguishes ASCII mode from binary (image) mode. ASCII mode converts line endings between operating systems, which suits plain text files; binary mode copies bytes unchanged and is required for archives, images and executables. Transferring a binary file in ASCII mode silently corrupts the file, a classic mistake that modern clients reduce through automatic type detection.
The REST command allows a client to resume an interrupted transfer from a byte offset, which matters on slow or unstable links. Extensions defined in later RFCs add SIZE, MDTM for modification time and MLSD for machine-readable directory listings, replacing the inconsistent output of LIST that clients once had to parse heuristically.
FTP compared with FTPS, SFTP and HTTPS
FTP is often confused with secure alternatives that solve the same problem differently. FTPS is FTP secured with TLS, either explicitly through the AUTH TLS command on port 21 or implicitly on port 990. SFTP is not FTP at all but a subsystem of SSH running over a single connection on port 22, and HTTPS can also carry uploads and downloads through ordinary web requests.
The table compares the protocols on the properties that usually drive a decision.
| Protocol | Encryption | Connections and ports | Authentication |
|---|---|---|---|
| FTP | None | Control 21 plus dynamic data ports | Password in plain text |
| FTPS | TLS on both channels | 21 or 990 plus data ports | Password, optional client certificate |
| SFTP | SSH transport | Single connection on 22 | Password or SSH keys |
| HTTPS | TLS | Single connection on 443 | Tokens, cookies, certificates |
For new systems, SFTP or HTTPS-based transfer is generally preferred because a single encrypted connection passes firewalls cleanly. FTPS remains common where existing FTP workflows must be secured without replacing client software, for example in banking file exchange and retail supply chains.
Security limitations and common mistakes
Plain FTP offers no confidentiality and no integrity protection. Anyone on the network path can capture the user name, password and file contents, and an attacker in the middle can alter data without detection. Major browsers removed FTP support around 2021, which reflects how far the protocol has fallen from general use.
Additional risks come from configuration rather than the protocol itself. The table lists frequent problems, their causes and the usual remedies.
| Symptom or risk | Cause | Fix |
|---|---|---|
| Login works, listing hangs | Passive ports blocked or wrong advertised IP | Open port range, set external address |
| Corrupted archives | Transfer in ASCII mode | Force binary mode |
| Stolen credentials | Plain-text authentication | Use FTPS or SFTP |
| Server used as relay | FXP or PORT bounce allowed | Disable bounce and site-to-site transfers |
| Exposed public files | Anonymous FTP enabled by default | Disable anonymous access or isolate it |
- Never reuse FTP passwords for other systems, since they may already be exposed.
- Restrict users to their home directory (chroot) to limit damage from a compromised account.
- Log all sessions and review failed logins, because FTP servers attract automated password guessing.
Explained without jargon
FTP is an old and simple way to copy files between computers across a network. One line is used to talk, giving instructions such as which folder to open or which file to send. A second line opens briefly to carry the file itself.
The catch is that plain FTP sends everything openly, like writing a password on a postcard. For anything private, use a secure version such as FTPS or SFTP, which keep the conversation and the files hidden from anyone listening on the way.
A typical use case
A regional manufacturer runs older machine controllers on its factory floor that can only export production logs over FTP. The IT team sets up an internal FTP server on an isolated network segment, gives each controller its own account restricted to one directory, and configures a passive port range of 40000 to 40100 on the server firewall.
Every night, the controllers upload about 2 GB of log files in binary mode. A separate job then moves the files over SFTP to the central data platform, so plain FTP never crosses the corporate network or the Internet. The result is that legacy equipment keeps working without replacement, while credentials and production data stay protected outside the isolated segment.