FTP and SFTP are two protocols for transferring files between a server and a client computer. FTP port is 21 while SFTP port is 22. SFTP communicates via encrypted connection, while FTP uses plain-text (unsecured) communication.
This quick reference guide covers FTP and SFTP, how they work and the differences between them.
What is FTP & FTP Port Number?
FTP (File Transfer Protocol) is a client-server communication protocol used to transfer files between a client and a server. FTP port is 21.
File Transfer Protocol (FTP) Clint-Server Model and Authentication
For FTP communication to occur there has to be a server and a client.
FTP requires that clients authenticate with the server when they attempt to connect. Authentication is via clear-text, meaning the communication between the FTP client and FTP server is not encrypted.
This makes FTP communication insecure. Meaning that an intruder with access to the communication will be able to see user names, password and files transferred.
FTP connection can be Active or Passive. This determines how a data connection is established between the client and the server. In both connection types, the client creates a TCP (Transmission Control Protocol) connection to the server via FTP port 21.
In active FTP mode, the connection begins by the client listening for incoming data connections from a random port, FTP port M. The client then sends FTP command PORT to let the server know which FTP port it is listening on. Next, in the communication process the server initiates a data channel to the client from its port 20, the FTP server data port.
There are circumstances where the client is behind a firewall. A client behind a firewall may not be able to accept incoming TCP connections. In this circumstance, FTP Passive mode is used for the connection.
In Passive FTP mode, the client uses the control connection to send a PASV FTP command to the server. The client then receives an IP address and server port number from the server. Finally, the client uses the information received from the server to open a data connection from an arbitrary client FTP port to the IP address and port received.
FTP Port Numbers Explained
As described above, FTP uses two TCP connections for communication, FTP port 20 and 21. FTP port 21 is used to send control information from the server to the client. Port 21 is not used to send data files. The second FTP port, 20 is used to send data files between the server and the client.
What is SFTP & SFTP Port Number?
SFTP (SSH (or Secure) File Transfer Protocol) allows for file and data transfer over a connection secured using the SSH (Secure Shell) protocol. Unlike FTP in SFTP, communication between a client and a server is encrypted over SFTP port is 22.
Secure FTP (SFTP) Clint-Server Model and Authentication
Like FTP, SFTP communication occur between a client and a server. SFTP server requires a web server with the correct port (SFTP port 22 or any other port you choose to use).
The port must be forwarded to the FTP server from the firewall. Once you correctly install an SFTP server, an SSH Host key is generated. Users can then be created and assigned the necessary permissions that will allow them connect to the SFTP server.
To connect to a SFTP server, you require an SFTP Client. An SFTP Client could be a GUI or command line tool. The SFTP client authenticates and transfers files over a secure and encrypted connection to the SFTP server via SFTP port 22 (or the port specified in the SFTP server).
Differences Between FTP and SFTP
Apart from the TCP ports that FTP and SFTP use for connection, there are other differences between the two protocols.
The table below highlights the differences between the two protocols.
|1||Port||FTP runs on Port 21 and 20||SFTP uses port 22|
|2||Data Transmission||Uses two separate channels to send control information and transfer data.||SFTP combines control and data into secure packets and send them through a single channel.|
|3||Security||FTP communication is not encrypted. Meaning a third party could intercept the data.||On the other hand, SFTP is data is sent via encrypted connections. If an intruder intercepts the data, it will be meaningless to the hacker.|
|4||Firewall||FTP is not firewall friendly.||SFTP uses a single SFTP Port 22 for both inbound and outbound connections. This means that a single port can be opened in the firewall for SFTP communications.|
In this quick reference guide, I covered FTP, SFTP, FTP port and SFTP port. FTP runs on port 20 and 21 while SFTP port is 22.
If you have any question or comment use the “Leave a reply” form at the end of this guide. You could also share your experience so other readers can benefit from it.
Other Helpful Guides
- Active Directory Domain Services: Installation & Configuration
- What is Active Directory (Top 50 AD Questions Answered)