scp (secure copy) copies files over an encrypted SSH connection between hosts.
Basic Command Syntax
scp [options] source destination
Common Transfer Examples
# Upload local file to remote server
scp report.pdf [email protected]:/var/data/
# Download remote file to current local directory
scp [email protected]:/var/data/report.pdf .
# Transfer an entire directory recursively (-r)
scp -r ./dist/ [email protected]:/var/www/site/
# Transfer between two remote servers via local workstation
scp [email protected]:/data/db.dump [email protected]:/data/
Useful Options
| Option | Description |
|---|---|
-P <port> |
Specify custom SSH port (e.g. -P 2222) |
-r |
Recursively copy entire directories |
-C |
Enable compression during transfer |
-p |
Preserve modification times, access times, and permissions |
-l <limit> |
Limit bandwidth in Kbit/s (e.g. -l 800) |
-v |
Verbose debug output |