Compression and Performance
SCP performance can be tuned through compression, cipher selection, and bandwidth limiting. These options are especially useful for slow or metered connections.
Compression (-C)
Enables gzip compression on the SSH channel. Most effective for text-heavy data (logs, SQL dumps, config files). Less effective for already-compressed data (.tar.gz, .zip, images).
Example: Transfer Logs with Compression
Command:
scp -C ./access.log admin@server:/archive/
Output:
access.log 100% 500MB 55.0MB/s 00:09
Without -C, the same file might show 35.0MB/s on the same link — compression reduces the actual bytes sent.
| Data Type | Compression Benefit |
|---|---|
| Logs, CSV, SQL dumps | Significant (2-10x reduction) |
| Source code, configs | Good (2-5x reduction) |
Images, video, .tar.gz | Minimal or negative (CPU overhead) |
Cipher Selection (-c)
Different ciphers trade security margin for speed. On trusted internal networks, a faster cipher can boost throughput.
Available Ciphers
ssh -Q cipher
Output:
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com
chacha20-poly1305@openssh.com
Example: Use a Faster Cipher
Command:
scp -c aes128-gcm@openssh.com ./large-dataset.csv admin@server:/data/
Output:
large-dataset.csv 100% 2048MB 58.0MB/s 00:35
| Cipher | Relative Speed | Security |
|---|---|---|
aes128-gcm@openssh.com | Fastest | Good |
aes256-gcm@openssh.com | Fast | Very Good |
chacha20-poly1305@openssh.com | Moderate | Excellent |
aes256-ctr | Moderate | Very Good |
Bandwidth Limiting (-l)
Limits transfer speed in Kbit/s. Useful to prevent SCP from saturating the network.
| Desired Speed | -l Value |
|---|---|
| 1 MB/s | 8000 |
| 5 MB/s | 40000 |
| 10 MB/s | 80000 |
| 50 MB/s | 400000 |
Example: Limit to 5 MB/s
Command:
scp -l 40000 ./backup.tar.gz admin@server:/backups/
Output:
backup.tar.gz 100% 1024MB 5.0MB/s 03:25
Verbose and Debug (-v)
Use -v to see the full SSH handshake and transfer debug info. Stack up to three times (-vvv) for maximum detail.
Example: Debug a Slow Transfer
Command:
scp -v ./file.txt admin@server:/tmp/
Output:
Executing: program /usr/bin/ssh host server
debug1: Reading configuration data /home/user/.ssh/config
debug1: Connecting to server [192.168.1.100] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_ed25519 type 3
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/user/.ssh/id_ed25519
debug1: Authentication succeeded (publickey).
file.txt 100% 4096 2.0MB/s 00:00
Example: Maximum Verbosity
Command:
scp -vvv ./file.txt admin@server:/tmp/
Output:
(extensive debug output including key exchange details,
MAC algorithms negotiated, channel multiplexing, etc.)
file.txt 100% 4096 2.0MB/s 00:00
Performance Comparison
| Strategy | Best For | Flag |
|---|---|---|
| Compression | Text-heavy files over slow links | -C |
| Fast cipher | Large transfers on trusted networks | -c aes128-gcm@openssh.com |
| Bandwidth limit | Shared or metered connections | -l <kbps> |
| Tar + SSH pipe | Many small files | tar czf - dir | ssh host "tar xzf -" |
What's Next?
Learn how to transfer through bastion servers in Jump Host and Proxy.