Secure copy protocol

Source: Wikipedia, the free encyclopedia.
scp
Cross-platform
TypeCommand, Communication protocol
Websitewww.openssh.com

Secure copy protocol (SCP) is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol.[1] "SCP" commonly refers to both the Secure Copy Protocol and the program itself.[2]

According to OpenSSH developers in April 2019, SCP is outdated, inflexible and not readily fixed; they recommend the use of more modern protocols like SFTP and rsync for file transfer.[3] As of OpenSSH version 9.0, scp client therefore uses SFTP for file transfers by default instead of the legacy SCP/RCP protocol.[4]

Secure Copy Protocol

The SCP is a

TCP port 22 by default.[6] Like RCP, there is no RFC
that defines the specifics of the protocol.

Function

Normally, a client initiates an SSH connection to the remote host, and requests an SCP process to be started on the remote server. The remote SCP process can operate in one of two modes:

  • source mode, which reads files (usually from disk) and sends them back to the client, or
  • sink mode, which accepts the files sent by the client and writes them (usually to disk) on the remote host.

For most SCP clients, source mode is generally triggered with the -f flag (from), while sink mode is triggered with -t (to).[2] These flags are used internally and are not documented outside the SCP source code.

Remote to remote mode

In the past, in remote-to-remote secure copy, the SCP client opens an SSH connection to the source host and requests that it, in turn, open an SCP connection to the destination. (Remote-to-remote mode did not support opening two SCP connections and using the originating client as an intermediary). It is important to note that SCP cannot be used to remotely copy from the source to the destination when operating in password or keyboard-interactive authentication mode, as this would reveal the destination server's authentication credentials to the source. It is, however, possible with key-based or

GSSAPI methods that do not require user input.[2]

Recently, remote-to-remote mode supports routing traffic through the client which originated the transfer, even though it is a 3rd party to the transfer. This way, authorization credentials must reside only on the originating client, the 3rd party.[7]

Issues using talkative shell profiles

SCP does not expect text communicating with the SSH login shell. Text transmitted due to the SSH profile (e.g. echo "Welcome" in the .bashrc file) is interpreted as an error message, and a null line (echo "") causes SCP client to deadlock waiting for the error message to complete.[2]

scp program

The SCP program[8] is a software tool implementing the SCP protocol as a service daemon or client. It is a program to perform secure copying.

Perhaps the most widely used SCP program is the OpenSSH

SFTP protocol; an -O option is added for using SCP with old SCP-only servers.[4]

Syntax

Typically, a syntax of scp program[9] is like the syntax of cp (copy):

Copying local file to a remote host:

scp LocalSourceFile user@remotehost:directory/TargetFile

Copying file from remote host and recursively copying folder (with -r switch) from remote host:

scp user@remotehost:directory/SourceFile LocalTargetFile
scp -r user@host:directory/SourceFolder LocalTargetFolder

Note that if the remote host uses a port other than the default of 22, it can be specified in the command. For example, copying a file from host:

scp -P 2222 user@host:directory/SourceFile TargetFile

Other clients

As the Secure Copy Protocol implements file transfers only,

directory listing at least). For example, WinSCP defaults to the SFTP protocol.[10] Even when operating in SCP mode, clients like WinSCP are typically not pure SCP clients, as they must use other means to implement the additional functionality (like the ls command).[11]
This in turn brings platform-dependency problems.

More comprehensive tools for managing files over SSH are SFTP clients.

Security

In 2019 vulnerability

openssh
SCP tool and protocol allowing users to overwrite arbitrary files in the SCP client target directory.

See also

References

  1. ^ "Linux and Unix scp command". Computer Hope. Retrieved 4 August 2015.
  2. ^ a b c d Pechanec, Jan. "How the SCP protocol works". Jan Pechanec's weblog. Oracle. Archived from the original on 2017-02-15. Retrieved 4 August 2015.
  3. ^ "OpenSSH 8.0". OpenSSH Release Notes. 17 April 2019.
  4. ^ a b "OpenSSH 9.0". OpenSSH Release Notes. 8 April 2022.
  5. ^ "scp(1) - OpenBSD manual pages (history section)". Retrieved 25 June 2012.
  6. ^ "SCP - Secure Copy Protocol - What is it & Full Definition & Example Cmds!". PC & Network Downloads - PCWDLD.com. 2019-06-29. Retrieved 2020-05-22.
  7. ^ Carroll, Brandon (16 August 2017). "How to use Secure Copy for file transfer". TechRepublic. Retrieved 2020-05-22.
  8. ^ "Portable OpenSSH". GitHub. 13 May 2022.
  9. ^ "scp(1) - OpenBSD manual pages" https://man.openbsd.org/scp
  10. ^ "Supported File Transfer Protocols :: WinSCP". winscp.net. Retrieved 2020-05-22.
  11. ^ "The SCP/Shell Page (Advanced Site Settings dialog) :: WinSCP". winscp.net. Retrieved 2020-05-22.
  12. ^ "NVD - Cve-2019-6111".