Show Contents / Index / Search

scp Command Line Utility

Syntax: scp [options] [user@host:]file1 [user@host:]file2

The scp command line utility copies files securely between hosts on a network. It uses Secure Shell sftp subsystem for data transfer, and uses the same authentication and provides the same security as Secure Shell. 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.

Examples

This command line copies the file f1 from the host to the local machine and gives it the name f2:

scp user@host:f1 f2

This command copies the local file f1 to f2 on the remote host.

scp f1 user@host:f2

Note: You can reuse an existing SecureShell connection. However, to do so you must explicitly enable this on each command line, or set the SSHConnectionReUse environment variable to Yes. For details, see Connection Reuse in Secure Shell Sessions.

Options

The following options are available:

-a

Transfer files in ASCII mode.

-b buffersize

Sets the maximum buffer size for one request.

-B

Sets batch mode on, which prevents asking for passwords or passphrases. Use passphraseless user keys to authenticate.

-c cipher

Protocol version 1 allows specification of a single cipher. The supported values are "3des", "blowfish", and "des".

For protocol version 2, a comma-separated list of ciphers can be specified in order of preference. Multiple ciphers must be comma-separated. The default is "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour, aes192-cbc,aes256-cbc". If the connection is set to run in FIPS mode, the default is "aes128-cbc,3des-cbc".

-C

Enable compression.

-d

Force target to be a directory.

-F configfile

Specifies an alternative per-user configuration file. If a configuration file is given on the command line, the system-wide configuration file will be ignored.

-H scheme

Specifies which SSH configuration scheme to use for this connection.

-i keyfile

Selects a file from which the identity (private key) for RSA or DSA authentication is read. Identity files may also be specified on a per-host basis in the configuration file. It is possible to have multiple -i options (and multiple identities specified in a configuration file). Path names containing spaces must be embedded inside double quotation marks.

-k directory

Sets a non-default folder for configuration file, host keys and user keys.

-l limit

Limit the bandwidth to the value specified (in Kb).

-o option

Can be used to give options in the format used in the configuration file. This is useful for specifying options for which there is no separate command-line flag. For a list of supported options, see the Configuration Keyword Reference.

-p

Preserve timestamps and file attributes.

-P port

Port to connect to on the remote host.

-q

Quiet mode. Causes all warning and diagnostic messages, including banners, to be suppressed.

-r

Copy directories recursively, including all subdirectories.

-u

Remove the source file after copying.

-v

Verbose mode. Causes ssh to display debugging messages about its progress. This is helpful in debugging connection, authentication, and configuration problems. Multiple -v options increases the verbosity. Maximum is 3 (-vvv).

-V

Display the version number and application information.

-1

Forces protocol version 1 only. This option also transfers file to OpenSSH servers using rcp through the ssh -2 tunnel.

-2

Forces protocol version 2 only.

-4

Use only IPv4 addresses.

-6

Use only IPv6 addresses.