+5 votes
231 views
in Know how by (242k points)
reopened
What is the SCP protocol?

1 Answer

+3 votes
by (1.6m points)
edited
 
Best answer

What is SCP?
How does the transmission work with the SCP protocol?
Where and how is SCP used (with example)?
The main SCP commands at a glance

image

What is the SCP protocol?

There are several types of tools and technologies available to anyone who wants to transfer data between two computers. A wide variety of client programs and protocols are available to less experienced or inexperienced users . This range of options can make it difficult to find the right solution for a planned data transfer. In particular, when what is sent is sensitive data , as it is more than a simple transfer from A to B. In this case, only those methods that offer adequate security come into play..

One such method is data transfer via Secure Copy Protocol (SCP), specifically designed for the secure transfer of digital information . The article below reveals what is behind the SCP protocol and how exactly it works.

Index
  1. What is SCP?
  2. How does the transmission work with the SCP protocol?
  3. Where and how is SCP used (with example)?
  4. The main SCP commands at a glance

What is SCP?

Secure Copy Protocol (SCP), often referred to simply as Secure Copy, is a protocol for computer systems, which ensures the secure transfer of data between a local computer ( local host ) and a remote computer ( remote host ) or, alternatively, between two remote computers . It is based on the RCP commands , ( remote copy ), which were released in 1982 as part of the? R? Commands. from the University of California (Berkeley). They allow the control of data transmission through the command line..

SCP offers an authentication method between the two computers, as well as transmission encryption . Therefore, the protocol not only guarantees the security, but also the authenticity of the transferred data. In both security mechanisms, the SCP protocol is based on SSH (Secure Shell), which is also used in alternative transmission protocols such as FTP (or SFTP). The TCP port that you use for transfer over SCP is the standard SSH port 22 .

Secure Copy is cross-platform: there are applications and programs for the most popular operating systems, such as Windows , macOS and Linux , as well as for Android and iOS ..

How does the transmission work with the SCP protocol?

Secure Copy requires an authentication of the two computers involved. In order for the transmission to be carried out through the protocol, an SSH connection must first be established from the local computer to the remote destination computer. This requires either the SSH access data or an authorized key for public key authentication .

Note

If SCP is used to transfer files between two remote computers , an SSH connection will be required from the local system running the SCP client on the remote computer, which in this case acts as the source computer.

Once the SSH connection between the two computers is established, the SCP client starts a secure copy process in which two different modes are available:

  • Source mode - A source mode SCP request reads files on the target system and sends them back to the client.
  • Sink mode : used in requests through the SCP protocol in sink mode client pages , it tells the remote system that it is incoming data and that it must be written to the system.

The CPS customers often use the indicator -f (of the English from, ? Of?) In order to activate the source mode. If sink mode is started to send data to the target computer, the -t ( to ,? A?) Flag will be used instead .

Note

The interaction between Secure Copy and Secure Shell can be interrupted by possible welcome messages when an SSH login occurs. As SCP is not ready for text messages, it interprets them as error messages and blocks the transfer accordingly.

Where and how is SCP used (with example)?

Secure Copy is compatible with all major operating systems as standard, and with the addition of SSH, it offers an excellent security package. The combination of authentication and encryption puts it on par with the popular SFTP protocol, which also takes advantage of Secure Shell's protection mechanisms. Since SCP also leads the FTP variant in terms of transmission speed , the protocol is an excellent alternative when it comes to transferring files safely and quickly to a web server or sharing sensitive data on a local area network (for example, on a corporate network) .

Note

In 2019, the American National Institute of Standards and Technology published an official security report that put the vulnerabilities of the different SCP applications on the table . It primarily addresses the potential risk of a middle man attack during SCP transfer that allows attackers to overwrite files in the target directory or smuggle malware in. Clients affected include Putty PSCP, OpenSSH, and WinSCP, among others.

In addition to the aforementioned clients, which can be downloaded and used for free from the web, MacOS, Windows and Linux are also equipped as standard with a Secure Copy client called scp . The path from the input request or terminal is therefore the quickest and easiest solution for transferring data through the SCP protocol, as the following two input examples illustrate :

  scp archivo de origen test@host:directorio/archivo de destino  

With this command, each source file is copied to the specified directory on the target machine , where the user must be logged in via SSH with the name? Test ?. If a file from a remote system is transferred to the local SCP participant, the command would be as follows:

  scp test@host:directorio/archivo de destino  

The main SCP commands at a glance

The basic syntax of command lines for controlling the native SCP client on Windows and other operating systems has already been made clear from the previous examples. However, both code samples only show a simple copy process that does not include additional options that the SCP tool does. If these options are part of a command, they precede the information about the files and the computers , so that the complete syntactic structure would be as follows:

  scp [Opcion(es)] [archivo de origen] [usuario@host:directorio/archivo de destino] scp [Opcion(es)] [usuario@host:directorio/archivo de origen] [archivo de destino]  

The main options for customizing Secure Copy queries with SCP are summarized in the following table:

SCP option Function
-1 Give the order to use version 1 of the SCP protocol
-2 Give the order to use version 2 of the SCP protocol
-C Enable GZIP compression of the encrypted SSH connection
-B Login without requesting password
-l limit Set a bandwidth limit (kbps) for file transfer
-o ssh_option Allows the definition of specific SSH options, such as encryption
-P port Specifies the port on the remote system through which the connection should be established
-p Preserves the original file metadata (such as changes and access times)
-q Hide progress markers during transfer
-r Copy the entire directory recursively, including subdirectories
-S program Specifies the program to be used for the encrypted connection (the program must support SSH options)

...