SFTP Protocol
SFTP (SSH File Transfer Protocol) is a file transfer protocol based on SSH (Secure Shell), used to securely transfer files between a client and a server.
Compared with traditional FTP Unlike FTP, SFTP protects data transmission through encrypted communication, making it suitable for transferring sensitive information.
How SFTP Works
SFTP uses a client-server model and transfers files through SSH's encrypted channel. Its core function is to transfer files securely.
1. SFTP Connection Establishment

- The client connects to the server's port 22 (the default SSH port).
- The server sends its public key to the client.
- The client verifies the server's public key.
- The client and server negotiate an encryption algorithm.
- The client generates a session key, encrypts it with the server's public key, and sends it.
- Both parties use the session key to encrypt subsequent communication.
2. File transfer
After the connection is established, the client can transfer files via SFTP. The following is a typical file transfer process:

- Upload files: The client uploads a local file to the server.
- Download Files: The client downloads a file from the server to the local machine.
3. Connection Closure
After the file transfer is complete, the client can close the connection:

- The client requests to exit the SFTP session.
- The server closes the connection.
Key Features of SFTP
-
Encrypted Communication:
-
Authentication:
-
File operations:
-
Directory operations:
-
Cross-platform support:
Applications of SFTP
SFTP is widely used in the following scenarios:
- File transfer: Securely transfer sensitive files.
- Backup and restore: Transfer backup files to a remote server.
- Software Distribution: Securely distribute software and updates.
- Data exchange: Exchange data within or outside an organization.
Security of SFTP
SFTP improves security through the following mechanisms:
- Encrypted transfer: Prevent data from being eavesdropped.
- Authentication: Verifies user identity through a password or public key.
- Data Integrity: Uses hash algorithms to ensure data has not been tampered with.
Alternatives to SFTP
In some scenarios, the following alternatives can be used:
- FTP: A traditional file transfer protocol, but insecure.
- FTPS: FTP based on SSL/TLS that encrypts data during transmission.
- SCP: A file transfer protocol based on SSH, but does not support directory operations.
In summary, SFTP is a secure file transfer protocol based on SSH that protects data transmission through encrypted communication and authentication mechanisms. It is widely used in file transfer, backup, and recovery scenarios and is an ideal choice for transferring sensitive information. If you are interested in a specific feature or application scenario of SFTP, feel free to explore further!