FTP and FTP Server

thuanvu301103thuanvu301103
4 min read

FTP (File Transfer Protocol)

What is FTP?

  • File transfer protocol (FTP) is an Internet tool provided by TCP/IP. The first feature of FTP was developed by Abhay Bhushan in 1971. It helps to transfer files from one computer to another by providing access to directories or folders on remote computers and allows software, data, and text files to be transferred between different kinds of computers. The end-user in the connection is known as localhost and the server which provides data is known as the remote host.

  • FTP is a standard communication protocol. There are various other protocols like HTTP which are used to transfer files between computers, but they lack clarity and focus as compared to FTP. Moreover, the systems involved in connection are heterogeneous systems, i.e. they differ in operating systems, directories, structures, character sets, etc the FTP shields the user from these differences and transfers data efficiently and reliably.

Is FTP secure?

  • Standard FTP is not encrypted, meaning data (including passwords) can be intercepted.

  • More secure alternatives:

    • FTPS – FTP over SSL/TLS (adds encryption)

    • SFTP – SSH File Transfer Protocol (not FTP, but often used for secure file transfers)


FTP Server

What is an FTP Server?

An FTP Server (File Transfer Protocol Server) is a computer or system that uses the FTP protocol to store, receive, and send files over a network such as the Internet or a local network.

FTP Client

What is FTP Client?

An FTP Client is a software application or command-line tool used to connect to an FTP Server and transfer files (upload/download) between a local computer and the server.

What does an FTP Client do?

Using an FTP Client, you can:

  • Connect to an FTP Server via IP address or domain name

  • Authenticate with a username and password (or anonymous login)

  • Navigate folders on the server

  • Upload files from your local system to the server

  • Download files from the server to your local machine

  • Rename, delete, or move files and folders

Common FTP Clients

  • Graphical FTP Clients (User-friendly interface):

    • FileZilla (very popular, free, cross-platform)

    • WinSCP (Windows only, also supports SFTP)

    • Cyberduck (macOS and Windows)

  • Command-Line FTP Clients:

    • ftp (built-in on many Unix/Linux systems)

    • lftp (more advanced, supports scripts and mirroring)

    • curl or wget (for simple FTP downloads)

Common Uses of FTP Servers:

  • Website deployment: uploading files to web hosting services.

  • Data backup: syncing or backing up data between servers.

  • Enterprise data exchange: transferring large volumes of files between systems.

  • CI/CD pipelines: transferring build artifacts, config files, or models.

FTP Connection

Connection Ports:

In traditional FTP (File Transfer Protocol), two ports are used to handle different parts of the connection

  • Port 21 – Control Connection:

    • This port is used to establish and manage the session between the client and the server.

    • Commands like USER, PASS, LIST, RETR, STOR, etc., are sent through this port.

    • It's called the control channel.

  • Port 20 – Data Transfer:

    • This port is used for actual file data transfer in Active Mode FTP.

    • Whenever you upload or download a file, the data itself (not the commands) flows through port 20.

Active vs. Passive Mode

  • Active Mode (traditional FTP)

    • Operations:

      • The client connects to the server’s port 21 (control channel).

      • Then the server connects back to the client from its port 20 to the port the client told it.

    • Often blocked by firewalls — because the server is trying to initiate a connection back to the client, and many firewalls reject that for security reason

  • Passive Mode (modern FTP)

    • Operations:

      • The client connects to the server’s port 21 (control channel).

      • The server opens a random port (e.g., 49152), and tells the client.

      • Then the client connects to that port for the data transfer.

    • Works well behind firewalls and NAT. No server-initiated connection.


Common FTP Server Operations

Connect to the FTP Server

  • Establish a connection using host, port (usually 21), username, and password.

  • Optionally use anonymous login (if the server allows it).

Browse Directories

  • List files and folders (LIST, NLST)

  • Change directories (CWD)

  • Check current directory (PWD)

Upload Files to Server

  • Send local files to the server using STOR

  • Upload multiple files or entire directories (depending on client capability)

Download Files from Server

  • Retrieve files from the server using RETR

  • Optionally resume broken downloads (if supported)

Delete Files or Directories

  • Remove files (DELE)

  • Remove empty directories (RMD)

Create Directories

Make a new folder on the server (MKD)

Rename Files or Folders

Rename items on the server (RNFR and RNTO)

Modify File Permissions (optional)

Some FTP servers allow changing file permissions (SITE CHMOD) – usually on UNIX-based servers.

View File Details

  • Get file size (SIZE)

  • Get last modified time (MDTM)

0
Subscribe to my newsletter

Read articles from thuanvu301103 directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

thuanvu301103
thuanvu301103