Show Contents / Index / Search

Secure File Copy (scp)

Use scp to copy files securely between the local computer and a remote host, or to transfer files securely between two remote hosts.

Both source and destination file names can include host and user specifications to indicate that files are to be copied to or from that host. Copies between two remote hosts are permitted. Wildcards are supported. When recursion is off (the default), name substitution occurs on file names only, not directories. When recursion is enabled (using -r), name substitution includes files and directories. By default, existing files are overwritten. To control overwrite behavior, use --overwrite. (If the files are identical no transfer occurs regardless of this setting value.)

Because scp uses authentication and encryption provided by ssh, a Secure Shell server must be running on the remote computer. Settings for scp connections are controlled by the ssh client configuration file. For details about these settings, see Client Configuration Keywords.

You can also use the -o option to configure settings on the scp command line. Command line options override configuration file settings.

Examples

The following samples show how you can use scp to transfer files securely — between a local computer and remote host, or between two remote hosts.

To

Example

Transfer a remote file (file1) to a specified local file (file2) and location

 

scp joe@myhost:/source/file1 /destination/file2

Copy all *.htm files from the current working directory on the local computer to joe's default directory on myhost.com

 

scp *.htm joe@myhost.com:.

 

Copy the specified file from remote host1 to remote host2

 

scp joe@host1:/dir/scr_file joe@host2:/dir/dest_file

Note: Two authentications are required.

Related Topics

scp Command Line Options