scp(1)
Securely copy files between hosts using SSH protocol.
Synopsis
scp [OPTION]... [[user@]host1:]file1 ... [[user@]host2:]file2Description
scp copies files between hosts on a network using SSH for authentication and encryption. It can transfer files from local to remote, remote to local, or between two remote hosts. The syntax follows the pattern [user@]host:path for remote files and plain paths for local files.
scp is secure by default, encrypting all data in transit. It authenticates using SSH keys or passwords (if configured) and uses the same authentication mechanism as ssh.
Common options
| Flag | What it does |
|---|---|
-r | Recursively copy entire directories |
-P port | Specify SSH port (default 22) |
-p | Preserve file modification times and permissions |
-C | Enable compression during transfer |
-v | Verbose output; show transfer progress and debug info |
-i identity_file | Use specified private key for authentication |
-o option | Pass SSH option (e.g., StrictHostKeyChecking=no) |
-l limit | Limit bandwidth to specified Kbit/s |
-q | Quiet mode; suppress progress meter and non-error messages |
Examples
Copy local file to remote host's home directory
scp file.txt [email protected]:/home/user/Copy remote file to current local directory
scp [email protected]:/home/user/file.txt .Recursively copy entire local directory to remote host
scp -r /local/folder [email protected]:/remote/path/Copy file using non-standard SSH port 2222
scp -P 2222 file.txt [email protected]:/tmp/Copy between two remote hosts using specific key and preserving permissions
scp -i ~/.ssh/id_rsa -p user@host1:/file.txt user@host2:/tmp/Copy large file with compression and 1 Mbps bandwidth limit
scp -C -l 1024 largefile.zip [email protected]:~/Recursively copy with verbose output showing transfer details
scp -r -v /local/src/ [email protected]:~/backup/