Download Files from a Linux Server via SCP

scp syntax for downloading a single file, an entire directory, and copying directly between two remote servers — without a third download.

By DevStudio Online Team · Published September 3, 2026

scp (secure copy) moves files over the same SSH connection you already use to log in — no separate FTP setup, no extra port to open. The syntax is the same in both directions; only the order of source and destination changes.

Download a single file

scp youruser@your-server.com:/var/www/app/logs/error.log ./error.log

Read it as scp <source> <destination> — the remote path comes first here because you're pulling from the server to your current local directory (./).

Upload a single file (the reverse)

scp ./backup.sql youruser@your-server.com:/tmp/backup.sql

Same command, just with local and remote swapped — this is the part people find confusing at first, but it's genuinely just "source, then destination," same as cp.

Download an entire directory

scp -r youruser@your-server.com:/var/www/app/storage ./storage

-r (recursive) is required for directories — without it, scp will simply refuse and tell you the source is a directory, not a file.

Copying between two remote servers directly

scp -3 serverA:/data/export.csv serverB:/data/import.csv

-3 routes the transfer through your own machine rather than attempting a direct server-to-server connection (which usually fails unless the two servers already trust each other's SSH keys). It's slightly slower than a truly direct copy, but it works reliably from a normal laptop with SSH access to both.

A non-standard SSH port

scp -P 2222 youruser@your-server.com:/tmp/file.txt ./file.txt

Note the capital -P for scp — this trips people up because the regular ssh command uses a lowercase -p for the same purpose. Different flag, same idea, easy to typo.

When to reach for rsync instead

scp copies the whole file every time, even if 99% of it is unchanged. For anything you'll sync repeatedly — a large directory, a periodic backup pull — rsync only transfers the parts that actually changed:

rsync -avz youruser@your-server.com:/var/www/app/storage/ ./storage/

For a true one-off download, scp is simpler and just as fast; for anything repeated, rsync will save real time and bandwidth.

Related tool

SSH Manager — browse and download server files from your browser

More Server guides