Skip to main content

SCP Cheatsheet

A fast operational reference for all SCP flags and everyday patterns.

All Flags

FlagDescriptionExample
-rRecursive (copy directories)scp -r ./dir/ host:/path/
-P PORTCustom SSH portscp -P 2222 file host:/path/
-i KEYIdentity file (SSH key)scp -i ~/.ssh/key file host:/path/
-CEnable compressionscp -C file host:/path/
-c CIPHERSelect cipherscp -c aes128-gcm@openssh.com file host:/path/
-l LIMITBandwidth limit (Kbit/s)scp -l 8000 file host:/path/
-pPreserve timestamps and modesscp -p file host:/path/
-qQuiet mode (no progress)scp -q file host:/path/
-vVerbose (debug output)scp -v file host:/path/
-F CONFIGCustom SSH config filescp -F /etc/ssh/conf file host:/path/
-o OPTIONPass SSH optionscp -o StrictHostKeyChecking=no file host:/path/
-J JUMPProxyJump (bastion host)scp -J user@bastion file host:/path/
-3Route remote-to-remote via localscp -3 hostA:/f hostB:/f
-4Force IPv4scp -4 file host:/path/
-6Force IPv6scp -6 file host:/path/
-BBatch mode (no password prompt)scp -B file host:/path/
-S PROGCustom SSH programscp -S /usr/bin/ssh file host:/path/
-OLegacy SCP protocolscp -O file host:/path/
-D PATHDirect SFTP server programscp -D /usr/lib/sftp-server file host:/path/
-TDisable filename checkscp -T file host:/path/
-sUse SFTP subsystemscp -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/s4000
1 MB/s8000
5 MB/s40000
10 MB/s80000
25 MB/s200000
50 MB/s400000
100 MB/s800000