FTP (File Transfer Protocol)
1. Definition
FTP (RFC 959) is an application-layer protocol for transferring files between a client and a server over TCP. It is the standard mechanism for uploading/downloading web pages and files to/from a web server (e.g. publishing a site to the docroot).
| Property |
Value |
| Transport |
TCP, connection-oriented, reliable |
| Ports |
21 — control connection; 20 — data connection (active mode) |
| Model |
Client–server, two separate connections (out-of-band control) |
| Authentication |
Username + password (anonymous FTP uses anonymous + e-mail) |
| Statefulness |
FTP is stateful — server keeps working directory, type, mode per session |
CLIENT SERVER
+-------------+ control (port 21) +----------------+
| FTP CLI |<===================>| server-PI | commands/replies,
| | USER,PASS,PWD,LIST| | stay open all session
| | +----------------+
| | data (port 20 active / random passive)
| |<===================>| data transfer |
+-------------+ RETR,STOR +----------------+
6. Security Concerns and Secure Alternatives
FTP weaknesses: credentials and data are transmitted in clear text (sniffable), no integrity check, vulnerable to brute-force and bounce (PORT) attacks.
| Secure alternative |
Basis |
| FTPS (FTP Secure) |
FTP + TLS/SSL (explicit AUTH TLS or implicit port 990) |
| SFTP |
SSH File Transfer Protocol — one encrypted connection over SSH (port 22) |
| scp / rsync over SSH |
Encrypted copy/sync |
7. FTP vs HTTP
| Aspect |
FTP |
HTTP |
| Purpose |
File transfer (upload/download) |
Resource/document retrieval |
| Connections |
Two (control + data) |
One (request/response) |
| State |
Stateful |
Stateless |
| Auth |
User/password login |
Usually none (or via headers) |
| Ports |
21 / 20 (or passive) |
80 / 443 |
| Encryption |
None (needs FTPS/SFTP) |
HTTPS/TLS |
8. Exam Points
- Explain FTP architecture with control and data connections (diagram) — 10 marks (very frequent).
- Explain active vs passive mode with the port handshake — 5-7 marks.
- Why is FTP stateful while HTTP is stateless? — 5 marks.
- Short note: FTP security issues and secure alternatives (FTPS/SFTP) — 5 marks.