What is FTP?

Ahmed Khan
what is ftp

What Is FTP and Why Does It Still Matter?

FTP stands for File Transfer Protocol, a standardized network protocol used to transfer files between computers over TCP/IP networks. First proposed in a 1971 MIT whitepaper, FTP was designed to enable reliable file exchanges between heterogeneous systems—computers with different operating systems, directory structures, and file architectures.

Despite being over 50 years old, FTP remains relevant in 2026 for several reasons:

  • Legacy system integration: Many industrial devices, embedded systems, and older servers still rely exclusively on FTP.
  • Web development workflows: Developers frequently use FTP to upload website files to hosting servers.
  • Backup and replication: Organizations use FTP for automated backup routines and data replication between locations.
  • B2B data exchanges: Some industries, particularly finance and logistics, still depend on FTP for partner file transfers.

However, FTP’s age also means it carries significant security limitations that modern businesses must address. Understanding what is FTP—including its strengths, weaknesses, and alternatives—is critical for anyone responsible for digital infrastructure.


How FTP Works:

Unlike most modern protocols that use a single connection, FTP operates using two parallel TCP channels. This dual-channel design is fundamental to understanding both FTP’s capabilities and its complexities.

The Control Connection (Port 21)

The control connection handles all commands and responses between the client and server. When you initiate an FTP session, your client connects to the server’s port 21 and keeps this connection open for the entire duration of the session.

All authentication (username and password), directory navigation commands, and file operation requests travel over this channel as plain, readable text. This is where the security vulnerability originates: credentials and commands are transmitted unencrypted.

what is ftp two connection

The Data Connection (Port 20 or Dynamic)

The data connection carries the actual file contents and directory listings. This connection opens only when a transfer is initiated and closes immediately after the transfer completes.

FTP’s data channel behavior differs depending on the mode:

ModeWho Initiates Data ConnectionPort BehaviorFirewall Compatibility
ActiveServer connects to clientServer uses port 20Poor (blocked by most firewalls)
PassiveClient connects to serverServer assigns random high portBetter (client-side firewalls allow outbound)

Step-by-Step FTP Transfer Process

A typical FTP session follows these stages:

  1. Connection establishment: The FTP client connects to the server on port 21.
  2. Authentication: The client sends USER and PASS commands (in plain text).
  3. Command channel setup: The control connection remains open throughout the session.
  4. Data channel negotiation: Depending on active or passive mode, the data connection is established.
  5. File transfer: The actual file data flows over the data channel.
  6. Session termination: When complete, the client sends QUIT and both connections close.

This separation of control and data channels enables FTP to support advanced features like resuming interrupted transfers and transferring files directly between two servers (FXP), but it also creates significant firewall and security challenges.


FTP Modes Explained: Active vs. Passive

Understanding the difference between active and passive FTP modes is crucial for troubleshooting connection issues—especially when firewalls or NAT (Network Address Translation) devices are involved.

what is ftp active vs passive ftp

Active Mode: The Original Design

In active mode, the workflow is:

  1. Client connects to server on port 21 (control channel).
  2. Client sends a PORT command containing its own IP address and a port number.
  3. Server initiates the data connection from port 20 to the client’s specified port.

The problem: From a firewall perspective, this looks like an unsolicited inbound connection from an external server to a random high port on your internal network. Most stateful firewalls block this by default.

Passive Mode: The Modern Default

In passive mode, the workflow is:

  1. Client connects to server on port 21 (control channel).
  2. Client sends a PASV command.
  3. Server responds with an IP address and a random high port number (e.g., 227 Entering Passive Mode (10,20,30,40,156,68)).
  4. Client initiates the data connection outbound to that server port.

The advantage: Outbound connections from the client are typically allowed by firewalls. The trade-off is that the server must open a wide range of ports (often 10,000+) to accommodate passive mode connections.

Which Mode Should You Use?

For most modern scenarios, passive mode is the default and recommended choice. Nearly all contemporary FTP clients default to passive mode because it works reliably across client-side firewalls and NAT gateways.

If you’re configuring an FTP server, you’ll need to:

  • Pin a specific passive port range in your server configuration.
  • Open that exact range in your server firewall.
  • Ensure your firewall allows inbound connections on those ports.

FTP Security Vulnerabilities: Why Plain FTP Is Risky

By modern standards, plain FTP is inherently insecure. The protocol was designed in an era when networks were small, trusted, and isolated—not the hostile, internet-connected environments we operate in today.

what is ftp plain ftp security risk

Critical Security Flaws

VulnerabilityImpactReal-World Risk
Credentials in plain textUsernames and passwords transmitted unencryptedAnyone with network access can capture login details
Data in plain textFile contents not encryptedSensitive files (configs, financial data) exposed in transit
No integrity verificationNo checksums or signaturesNo way to detect tampering or corruption
FTP bounce attackPORT command can redirect to arbitrary hostsAttackers can use your server as a relay to scan internal networks

Compliance Implications

If your organization handles protected health information (PHI), personally identifiable information (PII), or payment data, plain FTP fails most compliance frameworks:

  • HIPAA: Requires encryption of data in transit.
  • GDPR: Mandates appropriate technical measures for data protection.
  • PCI-DSS: Prohibits transmission of cardholder data over unencrypted channels.

Using plain FTP in these contexts requires extensive compensating controls (e.g., isolated network segments, VPNs, detailed risk documentation) and will likely raise red flags during audits.


Secure Alternatives: FTPS vs. SFTP

To address FTP’s security gaps, two encrypted alternatives emerged: FTPS (FTP Secure) and SFTP (SSH File Transfer Protocol). Despite similar names, they are fundamentally different protocols with distinct trade-offs.

FTPS: FTP Over TLS

FTPS wraps the existing FTP protocol in SSL/TLS encryption. It retains FTP’s dual-channel architecture but encrypts both control and data channels.

Two flavors of FTPS:

  • Explicit FTPS: Client connects on port 21, then sends AUTH TLS to upgrade to encryption. (Recommended)
  • Implicit FTPS: Client connects directly to port 990 with encryption from the first byte. (Deprecated by IETF in 2005)

Pros:

  • Strong encryption (TLS 1.2/1.3, AES-256).
  • Supports certificate-based (X.509) authentication.
  • Familiar FTP command set for legacy workflows.

Cons:

  • Firewall complexity: Encrypted control channel prevents firewalls from inspecting port negotiations.
  • Multiple ports: Still requires opening a wide range of ports for passive mode data channels.
  • Legacy baggage: Inherits FTP’s two-connection model and all associated operational headaches.

SFTP: A Completely Different Protocol

what is ftp encrypted connection

SFTP is not FTP at all. It is a file transfer subsystem that runs over SSH (Secure Shell) on a single encrypted connection, typically port 22.

Key characteristics:

  • One connection handles authentication, commands, and data.
  • All traffic encrypted by default—no unencrypted mode exists.
  • Supports SSH key-based authentication (no passwords stored on servers).
  • Built-in integrity checking and resume capability.

Pros:

  • Firewall-friendly: Single port (22) simplifies network configuration.
  • Strong security: Encryption, authentication, and integrity built into the protocol.
  • Modern tooling: Actively maintained (OpenSSH), widely supported.

Cons:

  • Different command set (not compatible with FTP clients without SFTP support).
  • Slight overhead from SSH handshake (negligible for most use cases).

Comparison Table: FTP vs. FTPS vs. SFTP

FeatureFTPFTPSSFTP
EncryptionNoneTLS 1.2/1.3SSH (AES-256, ChaCha20)
Ports Required21 + dynamic range21 (or 990) + dynamic rangeSingle port (22)
Firewall FriendlinessPoorPoorExcellent
AuthenticationPlain text passwordPassword or X.509 certPassword or SSH key
NAT TraversalComplicatedComplicated (encrypted passive)Simple
Compliance ReadyNoYes (if configured correctly)Yes
Resume Interrupted TransfersServer-dependentServer-dependentYes (protocol-level)
Active DevelopmentNoTLS layer isYes (OpenSSH)

Which Should You Choose in 2026?

For new deployments: Use SFTP. It’s simpler to operate, easier to firewall, and aligns with modern security best practices.

Use FTPS when:

  • You must integrate with a partner system that only supports FTPS (common in B2B EDI and financial exchanges).
  • Your compliance framework specifically requires X.509 certificate authentication.
  • You’re extending an existing FTP infrastructure and need encryption without changing the underlying protocol.

Use plain FTP only when:

  • You’re working with legacy hardware that physically cannot support anything else (e.g., PLCs, older security cameras, embedded devices with frozen firmware).
  • The devices are on an isolated network segment with no internet exposure.
  • You’ve documented the risk and implemented compensating controls.

Never use plain FTP on the public internet. Credentials and data will be intercepted.


Common FTP Commands and Response Codes

Understanding FTP’s command set and response codes is essential for troubleshooting and scripting automated workflows.

Essential FTP Commands

CommandPurposeExample Usage
USERSend usernameUSER john_doe
PASSSend passwordPASS secret123
CWDChange working directoryCWD /public_html
PWDPrint current directoryPWD
LISTList directory contents (human-readable)LIST
NLSTList filenames only (script-friendly)NLST
RETRRetrieve (download) a fileRETR file.zip
STORStore (upload) a fileSTOR backup.sql
DELEDelete a fileDELE old_file.txt
MKDMake a directoryMKD new_folder
RMDRemove a directoryRMD old_folder
TYPESet transfer type (ASCII or Binary)TYPE I (binary)
PASVEnter passive modePASV
QUITClose sessionQUIT

Critical note on TYPE: Always use TYPE I (binary mode) before transferring non-text files. ASCII mode (TYPE A, the default) converts line endings, which corrupts binary files like images, archives, or firmware.

FTP Response Codes

FTP servers respond with three-digit codes that indicate the status of each command.

CodeMeaningExample
220Service ready (greeting)220 FTP server ready
331Username OK, need password331 User name okay, need password
230User logged in230 User logged in
530Not logged in / bad credentials530 Not logged in
227Entering passive mode227 Entering Passive Mode (h1,h2,h3,h4,p1,p2)
150File status OK, opening data connection150 File status okay; about to open data connection
226Transfer complete, closing data connection226 Transfer complete
425Can’t open data connection (firewall issue)425 Can't open data connection
550File not found or permission denied550 File not found
421Service not available, shutting down421 Service not available

Reading response codes:

  • 1yz: Positive preliminary reply (command started, wait for another reply).
  • 2yz: Positive completion (command succeeded).
  • 3yz: Positive intermediate (command accepted, send the next command in sequence).
  • 4yz: Transient negative (temporary failure, retrying may work).
  • 5yz: Permanent negative (command failed, retrying won’t help).

Troubleshooting Common FTP Issues

Even with proper configuration, FTP connections can fail. Here are the most common problems and how to resolve them.

Issue 1: “425 Can’t Open Data Connection”

Symptoms: Login succeeds, but file transfers or directory listings fail with error 425.

Root cause: Firewall blocking the data connection.

Solutions:

  • Switch to passive mode in your FTP client settings.
  • If you control the server, configure a pinned passive port range (e.g., 50000-51000) and open it in the firewall.
  • Enable “FTP inspection” or “FTP fixup” on your firewall (works for plain FTP, not FTPS).

Issue 2: Corrupted Files After Transfer

Symptoms: Transfer completes successfully, but the file is unusable (e.g., images won’t open, archives fail to extract).

Root cause: File transferred in ASCII mode instead of binary mode.

Solutions:

  • Before transferring, explicitly set TYPE I (binary mode) in your client.
  • Most modern clients auto-detect file types, but embedded or legacy clients may not.
  • Always use binary mode for firmware, images, databases, and compressed files.

Issue 3: “530 Not Logged In” or “550 Permission Denied”

Enjoyed this article?

Browse more insights or get in touch about your project.