Skip to main content

What is SCP

SCP (Secure Copy Protocol) is a command-line utility that copies files between hosts on a network. It uses SSH for data transfer and provides the same authentication and security as SSH.

Quick Summary

SCP is the simplest way to copy files securely between two machines. If you can SSH into a server, you can use SCP to transfer files to and from it.

How SCP Works

sequenceDiagram
participant L as Local Machine
participant S as SSH Layer
participant R as Remote Server
L->>S: Authenticate (key or password)
S->>R: Establish encrypted tunnel
L->>R: Transfer file data (encrypted)
R-->>L: Confirm receipt
  1. SCP initiates an SSH connection to the remote host.
  2. After authentication, it opens an encrypted channel.
  3. File data is streamed through this channel.
  4. The connection closes once the transfer completes.

Key Characteristics

FeatureDetail
ProtocolSSH (port 22 by default)
EncryptionAlways encrypted in transit
AuthenticationSSH keys or password
ResumeNot supported (restarts from scratch)
Delta TransferNot supported (always full copy)
CompressionOptional (-C flag)
RecursiveSupported (-r flag)

SCP vs SFTP vs Rsync

CriteriaSCPSFTPRsync
SpeedFast (simple protocol)ModerateFast (delta only)
Resume TransfersNoYesYes
Interactive ModeNoYes (shell-like)No
Delta SyncNoNoYes
ScriptabilityExcellentGoodExcellent
Best ForQuick one-off copiesInteractive file managementRecurring syncs
When to Choose SCP
  • You need a single, quick file transfer and nothing more.
  • The remote host only has basic OpenSSH (no rsync installed).
  • You are scripting a simple deploy step where the file changes completely each time.
When to Avoid SCP
  • Large recurring backups → use rsync (delta transfer saves bandwidth).
  • Cloud storage → use rclone.
  • Resumable uploads → use sftp or rsync --partial.

Basic Syntax

scp [OPTIONS] SOURCE DESTINATION

Where SOURCE and DESTINATION can be:

  • A local path: /home/user/file.txt
  • A remote path: user@host:/path/to/file.txt

Examples with Output

1. Check SCP Availability

Command:

scp 2>&1 | head -1

Output:

usage: scp [-346ABCOpqRrsTv] [-c cipher] [-D sftp_server_path] [-F ssh_config]

2. Check SSH Version (SCP depends on it)

Command:

ssh -V

Output:

OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022

What's Next?

Continue to Installation and Setup to configure SSH keys for password-less SCP transfers.