---
title: What is Secure File Copy (scp)? | SSH Academy
description: 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.
---

[Academy ](https://www.ssh.com/academy)

# [What is Secure File Copy (scp)? | SSH Academy](https://www.ssh.com/academy/ssh/scp)

 Written by [Admin](https://www.ssh.com/academy/author/admin) | Sep 24, 2019 4:00:00 AM

`scp` is a program for copying files between computers. It uses the [SSH protocol](https://www.ssh.com/academy/ssh/protocol). It is included by default in most Linux and Unix distributions. It is also included in the [Tectia SSH](https://www.ssh.com/products/tectia-ssh/) and [OpenSSH](https://www.ssh.com/academy/ssh/openssh) packages.

### Contents

[Basic usage](https://www.ssh.com/academy/ssh/scp?hs_amp=true#basic-usage) [Copying directory trees with `scp`](https://www.ssh.com/academy/ssh/scp?hs_amp=true#copying-directory-trees-with-scp) [Configuring public key authentication](https://www.ssh.com/academy/ssh/scp?hs_amp=true#configuring-public-key-authentication)

## 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](https://www.ssh.com/academy/ssh/authorized-keys-file). See [how to set up public key authentication](https://www.ssh.com/academy/ssh/public-key-authentication).

Don't forget to establish proper SSH key management practices. See [how to manage SSH keys](https://www.ssh.com/academy/iam/ssh-key-management).

[View full post](https://www.ssh.com/academy/ssh/scp)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Admin"
  },
  "dateModified" : "2025-04-29T13:21:02.879Z",
  "datePublished" : "2019-09-24T04:00:00Z",
  "headline" : "scp - Secure File Copy",
  "image" : {
    "@type" : "ImageObject",
    "height" : 60,
    "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
    "width" : 60
  },
  "mainEntityOfPage" : "https://www.ssh.com/academy/ssh/scp",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Academy"
  }
}
```