scp Copy files between machines over SSH
Copies files and folders to or from a remote machine using the same encrypted connection and logins as ssh. A remote path is written as user@host:path. Use it for quick one-off copies.
Synopsis
scp [OPTION]... SOURCE... DESTINATION
Common options
| Option or form | What it does |
|---|---|
-r | Copy folders recursively |
-P PORT | Connect to PORT on the remote machine. Capital P for scp, unlike ssh -p |
-i FILE | Use FILE as the private key to log in |
-p | Keep the original modification times, access times and file modes |
-C | Compress data in transit. Can help on slow links |
-q | Quiet mode: hide the progress meter and warnings |
-v | Verbose mode. Prints debugging messages, useful when a connection fails |
-J HOST | Connect through a jump host |
Examples
scp report.pdf user@host:
scp user@host:/var/log/app.log .
scp -r photos user@host:/srv/media/
scp -P 2222 -i ~/.ssh/id_ed25519 report.pdf user@host:/tmp/
scp user@host1:/tmp/data.csv user@host2:/tmp/
Notes
- The port flag is capital -P in scp and lowercase -p in ssh. In scp, lowercase -p means preserve times and modes.
- scp overwrites existing files at the destination without asking.
- The colon matters. scp file user@host copies to a local file named user@host. scp file user@host: copies to the remote home folder.
- Paths on the remote side are read by the remote shell, so names with spaces need extra quoting. For large or repeated copies, rsync is usually a better tool because it can resume and skip unchanged files.
- Newer OpenSSH versions run scp over the SFTP protocol. The command line you type stays the same.
See also
Last reviewed 2026-10-07.