Vol. I · No. 46The protocol sectionSat, 10 Oct 2026
Layer 7 · Transfer · two connections, and a lot of history

FTP

File Transfer Protocol

FTP is older than almost everything else here. Unusually, it uses one connection for commands and a second for each file, sends its commands as readable text — and sends the password that way too, which is why it has been steadily replaced.

FTP splits commands and data onto separate connections — an elegant idea in 1971 that is now a firewall headache and a plaintext password.

You can run this one

Open the FTP lab →

Port 21 carries the conversation, not the file. Watch the second connection get negotiated, then see why a server-initiated active-mode connection is commonly blocked by NAT or a firewall.

Intermediate
Operates at
Layer 7
a text command dialog
Ports
21 · 20
control · data
Connections
Two
active or passive
Status
Superseded
use SFTP or FTPS

How it works

One channel to talk, another to carry the file
ClientServer
Control connection — port 21, stays open
USER anna → PASS … → 230 Logged on
Every command and its reply travel here, in readable text
PASV — “where should I connect for the data?”
227 Entering Passive Mode (203,0,113,7,195,80)
The server names a second port; the client opens the data connection to it
Data connection — the file itself, then closed
RETR report.pdf → the bytes flow on the second connection → 226 Transfer complete

In passive mode the client opens both connections, which is what lets FTP work from behind NAT. In the older active mode the server connects back to the client — and almost every firewall now refuses that.

The main points

What FTP does, step by step

1
Open the control channel

The client connects to port 21 and logs in with USER and PASS — in clear text unless FTPS is in use.

2
Agree a data channel

PASV (or the old PORT) settles which side opens the second connection and on which port.

3
Transfer the file

RETR, STOR or LIST runs over the fresh data connection, which closes when the transfer ends.

4
Repeat or quit

The control connection stays open for the next command; QUIT ends the session.

The variants
FTPS — FTP wrapped in TLS
SFTP — unrelated — file transfer over SSH
Anonymous FTP — the old public archive

In cybersecurity

FTP was designed for a network where nobody was listening. Credentials and data both cross in the clear, and the second connection defeats simple firewalling.

Plaintext credentials

USER and PASS are readable to anyone on the path — this alone disqualifies it.

Plaintext data

The file itself is unencrypted, so confidentiality and integrity are both absent.

Firewall complexity

The dynamic second port needs a protocol helper to inspect the control channel and open it.

Bounce attacks

The old PORT command could make a server open connections to a third party — port scanning by proxy.

Anonymous write

Writable anonymous servers became distribution points for whatever anyone uploaded.

Use SFTP or FTPS

Either encrypts credentials and content; SFTP also needs only one port.

Rides in the stack

IPTCPFTP

Two TCP connections rather than one — the control channel persists while data channels come and go.

Works with

SFTPTCP

See it on Linux

curlwget

Commands & modes

Commands
USER / PASSlog in
PASVpassive mode
RETR / STORget / put
LISTdirectory
Modes
Passiveclient opens both
Activeserver calls back
ASCIIline endings fixed
Binarybytes as-is