FTP Protocol
FTP (File Transfer Protocol) is a protocol used to transfer files over a network.
FTP allows users to upload or download files from one computer (client) to another computer (server).
FTP is one of the earliest protocols used on the Internet and is still widely used for file transfer today.
How FTP works
FTP uses a client-server model, communicating through two separate connections:
- Control connection: used to send commands and receive responses.
- Data connection: used to actually transfer files.
1. FTP connection establishment

- The client connects to the server's port 21 (the default control connection port).
- The server returns status code 220, indicating the service is ready.
- The client sends the username (USER command), and the server returns 331, indicating a password is required.
- The client sends the password (PASS command), and the server returns 230, indicating a successful login.
2. File transfer
FTP supports two modes for transferring files:
- Active mode: the server actively connects to the client's data port.
- Passive mode: the client connects to the server's data port.
Active mode

- The client sends the PORT command to inform the server of its own IP address and data port.
- The server connects to the client's data port and begins transferring files.
Passive mode

- The client sends the PASV command to request entering passive mode.
- The server returns its own IP address and data port.
- The client connects to the server's data port and begins transferring files.
Key features of FTP
-
Dual-connection model:
-
Supports multiple transfer modes:
-
Supports anonymous access:
-
Supports file operations:
-
Supports directory operations:
Application scenarios of FTP
FTP is widely used in the following scenarios:
- Website maintenance: uploading and downloading website files.
- File sharing: sharing files within or outside an organization.
- Software distribution: providing software download services.
FTP security
FTP itself is insecure because it transmits usernames, passwords, and data in plaintext during transmission. To improve security, the following alternatives can be used:
- SFTP: A file transfer protocol based on SSH that encrypts data during transmission.
- FTPS: FTP based on SSL/TLS that encrypts data during transmission.
In summary, FTP is a protocol used for file transfer, achieving file uploads and downloads through control and data connections. It supports active and passive modes, but attention should be paid to its security issues. If you are interested in a specific feature or application scenario of FTP, feel free to explore further!