Your browser does not allow storing cookies. We recommend enabling them.

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.

Basic usage

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. Often, path is just ., meaning the current working directory.

Copying directory trees with scp

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

Normally, scp asks for a password. To avoid this, or to automate file copying in scripts, public key authentication is usually used.

The basic idea is to create a key pair on the client and copy the public key to the server into an authorized keys file. See how to set up public key authentication.

Don't forget to establish proper SSH key management pratices. See how to manage SSH keys.


 

 
Highlights from the SSH.COM blog:

  • Cryptomining with the SSH protocol: what big enterprises need to know about it

    Cryptomining malware is primarily thought of as targeting desktops and laptops and is used to hijack system resources to mine cryptocurrency.
    Read more
  • SLAM the door shut on traditional privileged access management

    Did you know that something as trivial-sounding as granting access for your developers or third parties to a product development environment can throw a gorilla-sized monkey wrench into your operations and productivity?
    Read more
  • We broke the IT security perimeter

    Everyone understands the concept of a security perimeter. You only gain access if you are identified and authorized to do so.
    Read more