What Is SCP and SFTP?
SCP (Secure Copy Protocol)
This is a non-interactive file transfer that uses the shell and a remote command only, to securely transmit files between two computers. This is a secure version of the previous RCP, and FTP uses the SSH protocol for authentication but with a similar command-line syntax. While it is strongly based on the SFTP utility, SCP is usually a more suitable option when using scripts to set up unattended file transfers. The command can be used to send or retrieve a file to and from a server. Basically, it writes bytes of files onto the SSH tunnel and allows the SSH to deal with the more complex process such as integrity and compression. SCP can be used with wildcard statements as well when transferring multiple files based on your selected criteria. These wildcards can also be used to send and receive files. It also copies files between computers (local and remote) or between one remote host and another.
SFTP (Secure File Transfer Protocol)
Unlike SCP, which is non-interactive, SFTP is an interactive file transfer protocol or program that carries out all operations over an encrypted SSH transport. It uses several features, such as compression or public key authentication, to connect and log into the specific host and enters the interactive command mode. SFTP can refer to either Simple File Transfer Protocol or SSH File Transfer Protocol. The latter is designed for use with SSH for secure file transfers, while the Simple File Transfer Protocol is a lightweight FTP version abandoned in favor of TFTP. It runs on TCP port 115. It is also used to automatically retrieve files if you use a non-interactive authentication method; otherwise it retrieves them after successful interactive authentication. While it works with many protocols, SFTP commonly uses SSH for secure authentication. Note: SFTP isn’t FTP over SSH but is a new protocol altogether.
Differences between SCP and SFTP
A few similarities exist between both file transfer programs, like both use TCP port 22 and run on SSH making them equal in terms of security. They both offer features including encryption for data-in-motion, and public key authentication. Additionally, both protocols support transfer of large files, as they don’t have file size limits. The major differences between SCP and SFTP can be seen in their specifications and functions.
Functionality
SCP transfers data with protection from interception, while SFTP performs file access, transfer, and management functions. So while SCP is better-designed for one-time file transfers between two networked computers, or remotely over the Internet, SFTP does this plus manages that data.
Operations
SCP can’t perform some operations like remote directory listing or file removal; it can only transfer files. SFTP, on the other hand, performs everything, including file removal and directory listing tasks. SFTP offers a GUI component for more remote administration and is more like a remotely accessed file system, but SCP doesn’t offer that up.
File transfer speeds
SCP confirms received packets faster than SFTP, which has to acknowledge each tiny packet. This is especially so on high latency networks. The other advantage SCP has is that it uses a more efficient algorithm for file transfers.
Resumption of interrupted file transfer
SCP doesn’t support this function, but SFTP supports it through the command line client.
Command lines
SCP is non-interactive and can’t read command scripts, so everything has to be written on command lines. SFTP, on the other hand, is interactive, so it can read commands from files.
Which One Should You Use for File Transfer: SCP or SFTP?
While they have their similarities and differences, saying one is better than the other would not be fair. Both transfer files have similar security features as they run on SSH. The utility you choose will be based on what’s best for your environment’s requirements: speed, functionality, and security. Image Credits: SSH, Jama00