File Transfer Protocol

Gokhan Kosem
3 min readJun 27, 2023

What is FTP?

File Transfer Protocol (FTP) is a network protocol used in application layer of OSI Model or TCP/IP Model. With File Transfer Protocol (FTP), we can transfer files between two nodes that works as client and server. In other words, FTP is a file transfer protocol. And with such a working model, FTP is a Client/Server protocol like DHCP.

FTP is not a secure file transfer protocol. Because, it uses clear-text password and username for file transfers. Instead of FTP, SFTP (SSH File Transfer Protocol) is used as a secure alternative. With SFTP, encrypted passwords and usernames are used.

With FTP we can do data transfer over FTP ports. For example, we can download a file to an FTP Client from a remote FTP Server. Or we can upload a file from FTP Client to FTP Server. As a summary, FTP is the general name of file transfer in network World.

FTP uses two channels for file transfer. One of these channels is FTP control or FTP command channel. The other is FTP data channel. Different FTP ports are used for these channels.

The file transer with File Transfer Protocol is done over FTP ports. So, what are these ports of FTP?

What is an FTP Port?

As you know, there are various port types in network World. These ports are given below:

  • Well-known Ports
  • Registered Ports
  • Dynamic Ports

Well-known ports are the network ports between 0 and 1024. And two of these well-known ports are used as FTP ports. The ports used for FTP are TCP port 20 and TCP port 21. But FTP data port is TCP port 20 for Active FTP connections. In Passive FTP mode, any random port can be used for data channel.

Beside FTP, there are also simpler protocol TFTP (Trivial File Transport Protocol) and more secure protocols, SFTP (SSH File Transfer Protocol), SCP (Secure Copy Protocol) and FTPS (FTP over SSL). TFTP uses UDP port 69, SFTP uses TCP port 22 and FTPS uses TCP port 990. And SCP also uses TCP port 22. So, as a summary, ports of FTP are given below:

  • FTP TCP Port 20,21
  • TFTP UDP Port 69
  • SFTP TCP Port 22
  • SCP TCP Port 22
  • FTPS TCP Port 990

So, why FTP uses two FTP ports? Because FTP need two stage processes. It is a TCP service that uses two ports. Here, firstly, user enters the login credentials in the FTP Client and the control FTP Server port is opened. The default port for this command is TCP port 21 of the server. After that the data transfer is done over TCP port 20 of the FTP server. In other words, the first ftp port, port 21 is the command port that provide the communication between two ends. The second ftp port, port 20 is the data transfer port.

Normally the default control connection port of FTP is TCP port 21. But this is TCP port 990 for FTPS. When FTP server receives are request from TCP port 990, it immediately starts an SSL handshake for secure connection. Control connections over TCP port 21 requires additional security mechanism.

--

--