What is the difference between FTP and SFTP?

What is the difference between FTP and SFTP?

In actual project development, the most commonly used file transfer methods are FTP and SFTP, but what are the characteristics of these two transmission methods? This article will discuss the differences between SFTP and FTP.

1. FTP protocol

FTP is one of the protocols in the TCP/IP protocol suite. The TP protocol consists of two parts:

  • FTP server (for storing files)
  • FTP client (users can use FTP client to access resources located on FTP server through FTP protocol)

[[277923]]

By default, the FTP protocol uses TCP ports 20 and 21. Port 21 is used to transmit control information, and whether to use port 20 as the data transmission port depends on the transmission mode used by FTP. If the passive mode is used, the specific port to be used is determined by negotiation between the server and the client. There are two FTP transmission modes:

  • Active Mode(Port)
  • Passive

1. Active mode

The FTP client first establishes a connection with the TCP port 21 of the FTP server and sends commands through this channel. When the client needs to receive data, it sends the PORT command on this channel. The PORT command contains the port that the client uses to receive data. When transmitting data, the server connects to the client's specified port through its own TCP port 20 to send data.

2. Passive mode

The establishment of control channel is similar to active mode, but after the connection is established, the Pasv command is used. After receiving the Pasv command, the FTP server randomly opens a high-end port (port number greater than 1024) and notifies the client of the request to transmit data on this port. The client connects to this port of the FTP server, establishes a channel through three-way handshake, and then the FTP server transmits data through this port.

Note: Many firewalls are not allowed to accept connections initiated from the outside when they are set up, so many FTP servers located behind firewalls or in intranets do not support PASV mode, because the client cannot pass through the firewall to open the high-end port of the FTP server; and many intranet clients cannot log in to the FTP server in PORT mode, because TCP 20 from the server cannot establish a new connection with the client in the internal network, causing it to fail to work.

2. SFTP protocol

[[277924]]

SFTP is the abbreviation of SSH File Transfer Protocol, a secure file transfer protocol. SFTP and FTP have almost the same syntax and functions. SFTP is a part of SSH and is a secure way to transfer files to the Blogger server. In fact, the SSH software package already includes a secure file information transfer subsystem called SFTP. SFTP itself does not have a separate daemon process. It must use the sshd daemon process (the default port number is 22) to complete the corresponding connection and response operations. So in a sense, SFTP is not like a server program, but more like a client program.

3. The main differences between the two

[[277925]]

  • Connection mode: FTP uses the control connection on TCP port 21 to establish a connection. SFTP, on the other hand, uses the secure connection established between the client and the server through the SSH protocol (TCP port 22) to transfer files.
  • Security: SFTP uses encryption to transmit authentication information and transmitted data, so using SFTP is very safe compared to FTP.
  • Efficiency: SFTP uses encryption and decryption technology, so its transmission efficiency is much lower than that of ordinary FTP.

<<:  In-depth analysis of the seven major communication protocols of IOT

>>:  Kunpeng gathers data, shines in the Central Plains, and promotes the digital economy

Recommend

Network equipment and protocols: protocols

When visiting a website and sending or receiving ...

WiFi beginners guide: 4 things you need to know

Gone are the days of firing up our computers, plu...

Overview of the Latest Data Center Network Architecture Technologies

The network is the most important part of the dat...

Maxthon Hosting: 56 yuan/month Hong Kong CN2-2GB/40G SSD/300GB/15M Bandwidth

Aoyo Zhuji is one of the foreign hosting services...

Google's OnHub routers will stop supporting software in December next year

Google announced today that it will stop software...

With costs increasing by 30%, will mobile phone prices rise across the board?

This year is the explosive growth period for 5G c...

“Unlimited” is just a cover. Which data card is the most cost-effective?

In order to use more affordable mobile data, I be...