Linux / Unix Command: scp manul

Linux / Unix Command: scp
Command Library

NAME

scp - secure copy (remote file copy program)

SYNOPSIS

scp [-pqrvBC46 ] [-F ssh_config ] [-S program ] [-P port ] [-c cipher ] [-i identity_file ] [-o ssh_option ] [[user@ ] host1 : file1 ] [... ] [[user@ ] host2 : file2 ]

EXAMPLES

DESCRIPTION

scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.

Any file name may contain a host and user specification to indicate that the file is to be copied to/from that host. Copies between two remote hosts are permitted.

Ads

Putty Free Downloaddownloadputty.net/downloadDownload Putty Now. Fast and reliable SSH and SFTP.

EdgeWave's Email Securitywww.edgewave.comePrism Secure Email Solutions For Next Generation-Request A Quote Now

ClinicalKey Search Enginewww.ClinicalKey.comMost Relevant Clinical Data Faster. Try ClinicalKey® 30-Day Free Trial.

The options are as follows:

 

-c cipher
Selects the cipher to use for encrypting the data transfer. This option is directly passed to ssh(1).
-i identity_file
Selects the file from which the identity (private key) for RSA authentication is read. This option is directly passed to ssh(1).
-p
Preserves modification times, access times, and modes from the original file.
-r
Recursively copy entire directories.
-v
Verbose mode. Causes scp and ssh(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems.
-B
Selects batch mode (prevents asking for passwords or passphrases).
-q
Disables the progress meter.
-C
Compression enable. Passes the - C flag to ssh(1) to enable compression.
-F ssh_config
Specifies an alternative per-user configuration file for ssh This option is directly passed to ssh(1).
-P port
Specifies the port to connect to on the remote host. Note that this option is written with a capital `P' because - p is already reserved for preserving the times and modes of the file in rcp(1).
-S program
Name of program to use for the encrypted connection. The program must understand ssh(1) options.
-o ssh_option
Can be used to pass options to ssh in the format used in ssh_config5. This is useful for specifying options for which there is no separate scp command-line flag. For example, forcing the use of protocol version 1 is specified using scp -oProtocol=1
-4
Forces scp to use IPv4 addresses only.
-6
Forces scp to use IPv6 addresses only.
------------------------------

Secure copy or 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.

The term SCP can refer to one of two related things, the SCP protocol or the SCP program.

Contents

  • 1 SCP protocol
    • 1.1 How it works
    • 1.2 Remote to remote mode
    • 1.3 Issues using talkative shell profiles
  • 2 SCP program
  • 3 See also
  • 4 References

SCP protocol

The SCP protocol is a network protocol, based on the BSD RCP protocol,[1] which supports file transfers between hosts on a network. SCP uses Secure Shell (SSH) for data transfer and uses the same mechanisms for authentication, thereby ensuring the authenticity and confidentiality of the data in transit. A client can send (upload) files to a server, optionally including their basic attributes (permissions, timestamps). Clients can also request files or directories from a server (download). SCP runs over TCP port 22 by default. Like RCP, there is no RFC that defines the specifics of the protocol.

How it works

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 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 does not operate by 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]

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 intrepreted as an error message, and a null line (echo "") causes scp to deadlock waiting for the error message to complete.[2]

SCP program

The SCP program is a software tool implementing the SCP protocol as a service daemon or client. It is a program to perform secure copying. The SCP server program is typically the same program as the SCP client.

Perhaps the most widely used SCP program is the command line scp program, which is provided in most SSH implementations. The scp program is the secure analog of the rcp command. The scp program must be part of all SSH servers that want to provide SCP service, as scp functions as SCP server too.

Some SSH implementations provide the scp2 program, which uses the SFTP protocol instead of SCP, but provides the very same command line interface as scp. scp is then typically a symbolic link to scp2.

Typically, a syntax of scp program is like the syntax of cp:

Copying file to host:

scp SourceFile user@host:directory/TargetFile

Copying file from host:

scp user@host:directory/SourceFile TargetFile
scp -r user@host:directory/SourceFolder TargetFolder

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

As the SCP protocol implements file transfers only, GUI SCP clients are rare, as implementing it requires additional functionality (directory listing at least). For example, WinSCP defaults to the SFTP protocol. 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). This in turn brings platform-dependency problems.

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



你可能感兴趣的:(Linux / Unix Command: scp manul)