An FTP server is a computer program that is built to handle data transfer between computers. The server waits for clients to connect to it and issue commands that tell the server to upload, download, or list directories. The FTP protocol is the commands the FTP server uses to accomplish this.
File Transfer Protocol
As a protocol, FTP supports many operations that HTTP (which runs the web) does not, like file resume for interrupted transfers. As a transfer protocol, FTP is very fast and efficient and especially suited to transferring large files.
Most of the time, when you connect to an FTP server, you use an FTP client application. An FTP client is a piece of software you run on your computer that knows how to talk to an FTP server. There are a variety of clients you can use to transfer files. For example, FileZilla, Cyberduck, WinSCP, and Transmit are some popular FTP clients.
Most FTP clients support drag and drop interfaces, have easy ways to sync folders, and offer features that facilitate FTP transfers and simplify communication with the server. Behind the scenes, FTP clients interpret the actions that you do in the interface and translate that to FTP commands, which is what the server understands.
Communicating With an FTP Server
To show what an FTP client does to communicate with an FTP server, we can play the role of an FTP client and talk to the FTP server directly. This example will show you what happens when you log in and list a folder in an FTP client.
The first step is to establish a connection with the FTP server. The standard port for the FTP protocol is 21. The Telnet program is the simplest way to communicate with a server on a network interactively.
This command will connect to the ExaVault ftptest account on port 21.
> telnet ftptest.exavault.com 21 Trying 184.108.40.206... Connected to ftptest.exavault.com. Escape character is '^]'. 220 ProFTPD Server (EV) [220.127.116.11]
The output here shows that the FTP connection has been established, and the server has said hello in a response message with code 220 and a server identifier.
USER & PASS Commands
Next, we have to tell the server who we are. We need our username and password. The first step is done via the USER command:
> USER ftptest 331 Password required for ftptest
The server responded with a message including code 331, which means that a password is required to complete authentication. We supply the password using the PASS command:
> PASS [REDACTED] 230 User ftptest logged in
Success! The ftptest user has been logged into the server. Now we can issue commands to the server to work with data.
Let’s get a list of files in the account. First, we have to open a connection to receive the file and folder list.
Because FTP is a super old protocol, it handles data transfers very differently than modern protocols. It was in use before networks were smart enough to route traffic intelligently. So, when we want to transfer data over FTP, we have to ask the server what port number we will connect to so we can transfer data. This is what the PASV command is for.
When you run PASV, you get back an IP address of the server, followed by two numbers that identify the port. Usually, ports are expressed in a range between 0 and 65535. In this format, there’s an equation you have to use to figure out what the port number is.
You take the 5th number, multiply it by 256 and add the 6th number.
> PASV 227 Entering Passive Mode (67,208,93,232,245,123).
Our server tells us that it has opened a connection for us on a port identified by 245,123. Applying the equation from above gives us port 62843.
245 * 256 + 123 = 62843.
We need to open a new connection to port 62843 in order to get back data. We do this in another instance of Telnet.
> telnet ftptest.exavault.com 62843 Trying 18.104.22.168... Connected to ftptest.exavault.com. Escape character is '^]'.
On the first connection, we run a LIST command:
> LIST 150 Opening BINARY mode data connection for file list 226 Transfer complete
The FTP server tells us that it has completed the transfer, but the data is going to be sent to the other connection. So, switching to the second Telnet instance, we see the list:
drwxrwx--- 2 ftptest 10002 0 Jul 1 17:37 . drwxrwx--- 2 ftptest 10002 0 Jul 1 17:37 .. -rw-rw---- 1 ftptest 10002 29 Jun 12 14:59 .fspftpcheck.1591973977 -rw-rw---- 1 ftptest 10002 29 Jun 13 01:57 .fspftpcheck.1592013477 -rw-rw---- 1 ftptest 10002 29 Jun 13 03:16 .fspftpcheck.1592018214 -rw-rw---- 1 ftptest 10002 29 Jun 13 03:27 .fspftpcheck.1592018870 -rw-rw---- 1 ftptest 10002 29 Jun 13 05:09 .fspftpcheck.1592024965 -rw-rw---- 1 ftptest 10002 29 Jun 13 07:04 .fspftpcheck.1592031888 -rw-rw---- 1 ftptest 10002 29 Jun 13 08:31 .fspftpcheck.1592037063 -rw-rw---- 1 ftptest 10002 29 Jun 13 08:38 .fspftpcheck.1592037484 -rw-rw---- 1 ftptest 10002 29 Jun 13 08:51 .fspftpcheck.1592038283
As you’ve just seen, an FTP server works by taking commands from a client and delivering responses. FTP clients simplify the task of issuing these commands, opening ports when needed, and abstracting complex operations for the user.
Using a hosted FTP server allows you to send large amounts of data quickly. ExaVault offers secure FTP hosting services with modern features and is compatible with almost any FTP client.
Do you need an FTP server? Try ExaVault today!