SCP Cheatsheet
A fast operational reference for all SCP flags and everyday patterns.
All Flags
| Flag | Description | Example |
|---|---|---|
-r | Recursive (copy directories) | scp -r ./dir/ host:/path/ |
-P PORT | Custom SSH port | scp -P 2222 file host:/path/ |
-i KEY | Identity file (SSH key) | scp -i ~/.ssh/key file host:/path/ |
-C | Enable compression | scp -C file host:/path/ |
-c CIPHER | Select cipher | scp -c aes128-gcm@openssh.com file host:/path/ |
-l LIMIT | Bandwidth limit (Kbit/s) | scp -l 8000 file host:/path/ |
-p | Preserve timestamps and modes | scp -p file host:/path/ |
-q | Quiet mode (no progress) | scp -q file host:/path/ |
-v | Verbose (debug output) | scp -v file host:/path/ |
-F CONFIG | Custom SSH config file | scp -F /etc/ssh/conf file host:/path/ |
-o OPTION | Pass SSH option | scp -o StrictHostKeyChecking=no file host:/path/ |
-J JUMP | ProxyJump (bastion host) | scp -J user@bastion file host:/path/ |
-3 | Route remote-to-remote via local | scp -3 hostA:/f hostB:/f |
-4 | Force IPv4 | scp -4 file host:/path/ |
-6 | Force IPv6 | scp -6 file host:/path/ |
-B | Batch mode (no password prompt) | scp -B file host:/path/ |
-S PROG | Custom SSH program | scp -S /usr/bin/ssh file host:/path/ |
-O | Legacy SCP protocol | scp -O file host:/path/ |
-D PATH | Direct SFTP server program | scp -D /usr/lib/sftp-server file host:/path/ |
-T | Disable filename check | scp -T file host:/path/ |
-s | Use SFTP subsystem | scp -s file host:/path/ |
Common Patterns
File Transfer
# Local → Remote
scp ./file.txt user@host:/path/
# Remote → Local
scp user@host:/path/file.txt ./
# Remote → Remote
scp user@hostA:/path/file.txt user@hostB:/path/
Directory Transfer
# Push directory
scp -r ./project/ user@host:/opt/apps/
# Pull directory
scp -r user@host:/opt/apps/project/ ./
# With preserved attributes
scp -rp ./configs/ user@host:/etc/app/
Wildcards and Multiple Files
# All SQL files
scp ./*.sql user@host:/backups/
# Remote glob (must quote)
scp 'user@host:/var/log/*.log' ./logs/
# Multiple named files
scp file1.txt file2.txt user@host:/data/
# Brace expansion (remote, must quote)
scp 'user@host:/etc/{nginx.conf,hosts}' ./
Custom Port and Key
# Non-standard port
scp -P 2222 ./file.txt user@host:/path/
# Specific SSH key
scp -i ~/.ssh/deploy_key ./app.jar user@host:/opt/
# Both
scp -P 2222 -i ~/.ssh/key ./file.txt user@host:/path/
Jump Host
# Single jump
scp -J user@bastion ./file.txt admin@internal:/path/
# Chained jumps
scp -J user@jump1,user@jump2 ./file.txt admin@target:/path/
# Jump + recursive + compression
scp -J user@bastion -rC ./dir/ admin@internal:/path/
Performance
# Compress (good for text)
scp -C ./access.log user@host:/archive/
# Fast cipher
scp -c aes128-gcm@openssh.com ./large.csv user@host:/data/
# Bandwidth limit (5 MB/s)
scp -l 40000 ./backup.tar.gz user@host:/backups/
# Tar pipe (fastest for many small files)
tar czf - ./dir/ | ssh user@host "tar xzf - -C /opt/"
Debugging
# Verbose
scp -v ./file.txt user@host:/path/
# Maximum debug
scp -vvv ./file.txt user@host:/path/
Bandwidth Conversion Table
| Desired Speed | -l Value |
|---|---|
| 500 KB/s | 4000 |
| 1 MB/s | 8000 |
| 5 MB/s | 40000 |
| 10 MB/s | 80000 |
| 25 MB/s | 200000 |
| 50 MB/s | 400000 |
| 100 MB/s | 800000 |