scp

Securely copy files between local and remote hosts over SSH.

medium risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

scp uses SSH to transfer files. -r copies directories. Note: -P (capital) sets the port for scp, unlike ssh which uses lowercase -p. For large or resumable transfers prefer rsync.

Common flags
FlagMeaning
-rRecursively copy entire directories
-iSpecify private key
-PSpecify SSH port (capital P)
-pPreserve modification times and permissions
-CEnable compression during transfer
Examples
scp -i key.pem app.jar [email protected]:/opt/app/Upload JAR to remote server · explain & risk-check →
scp -rp user@host:/etc/nginx ./nginx-backup/Download nginx config directory preserving timestamps · explain & risk-check →
scp -P 2222 -C bigfile.tar.gz user@host:/tmp/Upload large file over non-standard port with compression · explain & risk-check →
Pro tip

For anything over a few MB, use `rsync -avz --progress` instead — it resumes interrupted transfers automatically.

Related
rsync ssh sftp curl
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man scp for your version. Test destructive commands on a non-production system first.