scp - Secure File Copy
scp is a program for copying files between computers. It uses the SSH protocol. It is included by default in most Linux and Unix distributions. It is also included in the [Tectia SSH}(/products/tectia-ssh/) and OpenSSH packages.
The basic usage of
scp is as follows:
scp file host:path
This copies the file to the remote host. The destination
path is optional, but can be a directory on the server, or even a file name if copying a single file. It is possible to specify multiple files; the last one is the destination.
To copy a file from the remote host, use:
scp host:file path
This fetches the file from the host, and puts it in the directory indicated by
path is just
., meaning the current working directory.
Copying directory trees with
To cpoy entire directory trees instead of single files, add the
-r option. For example:
scp -r host:path/directory .
This would fetch
path/directory from the host, copying it to the current working directory (creating
directory in current working directory).
Configuring public key authentication
scp asks for a password. To avoid this, or to automate file copying in scripts, public key authentication is usually used.
Don't forget to establish proper SSH key management pratices. See how to manage SSH keys.