FTP
✅ What is FTP?
FTP (File Transfer Protocol) is a standard network protocol used to transfer files between a client and a server on a computer network. It allows users to upload, download, rename, delete, and manage files on remote servers.
🔑 Key Characteristics of FTP:
Protocol Type
Application Layer Protocol (OSI Layer 7)
Connection Type
Connection-oriented (uses TCP)
Ports Used
Port 21 (Control), Port 20 (Data)
Transfer Type
Plaintext (default, not encrypted)
Secure Version
FTPS (FTP Secure via SSL/TLS), SFTP (over SSH)
Data Transfer
Upload and download files, manage directories
⚙️ How FTP Works (Basic Flow):
1. Establish Connection:
FTP client connects to FTP server via control connection (Port 21).
User provides login credentials (username, password) — unless anonymous login is allowed.
2. Command & Response:
Client sends FTP commands (e.g., LIST, GET, PUT).
Server responds with status codes and messages.
3. File Transfer:
Data connection (Port 20 or other negotiated port) is used to transfer files.
4. Disconnect:
After file operations, client disconnects from the server.
🔁 FTP Modes of Data Transfer:
Active
Client opens a port and listens, server connects to client to send data.
Passive
Server opens a port and listens, client connects to server for data (more firewall-friendly).
📡 Common FTP Commands:
USER
Provide username.
PASS
Provide password.
LIST
List directory contents.
RETR
Retrieve (download) a file.
STOR
Store (upload) a file.
DELE
Delete a file.
MKD
Make a directory.
RMD
Remove a directory.
PWD
Print working directory.
CWD
Change working directory.
QUIT
Close connection.
🔐 Secure Alternatives to FTP:
FTPS
FTP over SSL/TLS (encrypted)
21 (control), other for data
SFTP
SSH File Transfer Protocol (completely different, but secure)
22
💡 Note: SFTP is not FTP with SSH. It's a separate protocol that runs over SSH.
📊 Common FTP Status Codes:
200
Command OK
220
Service ready for new user
221
Closing control connection
331
Username OK, need password
425
Can't open data connection
530
Not logged in (login incorrect)
550
File not available (e.g., not found, no access)
⚙️ Example of FTP Session:
📥 Popular FTP Clients:
FileZilla
Windows, Mac, Linux
Free, open-source, user-friendly
WinSCP
Windows
Great for SFTP, SCP, FTP
Cyberduck
Mac, Windows
FTP, SFTP, WebDAV, cloud storage
Transmit
Mac
Premium, popular for Mac users
🌍 Common Use Cases of FTP:
Uploading websites to web hosting servers.
Sharing large files over the Internet.
Automated file transfers in businesses (via scripts).
Backup data to remote servers.
⚠️ FTP vs. SFTP (Comparison Table):
Port
21 (control), 20 (data)
22
Encryption
❌ No (plain text)
✅ Yes (via SSH)
Authentication
Username/Password
Username/Password or Key-based
Firewall-friendly
❌ Complex with active mode
✅ Simple, single connection
Secure?
❌ No
✅ Yes
✅ Summary of FTP:
Protocol
File Transfer Protocol
Port
21 (Control), 20 (Data)
Purpose
Transfer files between client and server
Secure Version
FTPS, SFTP
Commands
USER, PASS, LIST, RETR, STOR, QUIT
Transfer Modes
Active, Passive
Common Clients
FileZilla, WinSCP, Cyberduck
Last updated