Use scp for a quick one-off copy of a file or two, and rsync for anything you copy more than once, anything large, or anything that might get interrupted. Both run over SSH, but rsync skips files that haven't changed, sends only the changed parts of files that have, and can resume a broken transfer.
scp report.pdf alex@server:/home/alex/
rsync -avP ./photos/ alex@server:/backup/photos/
scp vs rsync at a glance
| scp | rsync | |
|---|---|---|
| Transport | SSH (SFTP protocol since OpenSSH 9.0) | SSH by default for host:path |
| Repeat copy of unchanged files | Copies everything again | Skips files with the same size and modification time |
| Changed files | Sends the whole file | Sends only the differences (delta transfer) |
| Resume after interruption | No | Yes, with --partial or -P |
| Delete files removed at the source | No | Yes, with --delete |
| Dry run | No | Yes, with -n / --dry-run |
| Needs software on the remote side | An SSH server with SFTP | rsync installed on both machines |
| Available on Windows out of the box | Yes (Windows OpenSSH client) | No; use WSL or a port |
What scp does well
scp is the simplest way to move a file over SSH, and it is already there: it ships with OpenSSH on Linux and macOS and with the OpenSSH client built into Windows 10 and 11. The syntax mirrors cp:
# upload
scp notes.txt alex@server:/home/alex/
# download
scp alex@server:/var/log/app.log .
# a whole directory
scp -r ./site alex@server:/var/www/
# non-standard SSH port (capital P)
scp -P 2222 notes.txt alex@server:~
The flags you'll actually use: -r copies directories recursively, -p keeps modification times and permissions, -P sets the port (capital, because -p was taken), -i picks a private key, -C turns on compression, and -l caps bandwidth in Kbit/s.
One change matters if you have older scripts. OpenSSH 9.0, released on 8 April 2022, switched scp from the legacy scp/rcp protocol to SFTP. The command looks the same, but remote wildcards no longer need the awkward double quoting the old protocol required, and ~user paths may behave differently on old servers. If a server lacks SFTP or a script breaks, scp -O forces the legacy protocol.
What rsync does that scp can't
rsync compares the source with what is already at the destination. By default it uses a "quick check": a file whose size and modification time match is skipped entirely. A file that did change is sent with the delta-transfer algorithm, which transmits only the parts that differ.
Here is real output from copying a folder of three 1 MiB files, then running the same command again, then running it after one file changed. Run on Ubuntu (WSL), rsync 3.2.7:
$ rsync -av photos/ backup/
sending incremental file list
created directory backup
./
2026/
2026/img1.jpg
2026/img2.jpg
2026/img3.jpg
sent 3,146,769 bytes received 113 bytes 6,293,764.00 bytes/sec
total size is 3,145,728 speedup is 1.00
$ rsync -av photos/ backup/
sending incremental file list
sent 146 bytes received 13 bytes 318.00 bytes/sec
total size is 3,145,728 speedup is 19,784.45
$ echo "change" >> photos/2026/img2.jpg
$ rsync -av photos/ backup/
sending incremental file list
2026/img2.jpg
sent 1,049,028 bytes received 36 bytes 2,098,128.00 bytes/sec
total size is 3,145,735 speedup is 3.00
The second run sent 146 bytes because nothing had changed. scp would have sent all 3 MB again. The third run copied only img2.jpg.
Notice that the changed file still went over in full (about 1 MB). That is because this test copied between two local folders, and the rsync manual says whole-file copying is the default "when both the source and destination are specified as local paths". Over the network, or with --no-whole-file, the delta algorithm kicks in. Appending a line to a 10 MiB file and syncing again with --no-whole-file --stats gave:
Literal data: 1,161 bytes
Matched data: 10,484,608 bytes
Total bytes sent: 14,266
total size is 10,485,769 speedup is 310.50
About 14 KB sent to update a 10 MB file. That is the case rsync was built for: large files that change a little, such as logs, disk images or database dumps.
The rsync flags worth memorising
-a(archive): recursive, and keeps symlinks, permissions, modification times, group, owner and device files. The manual defines it as-rlptgoD. It does not include hard links (-H), ACLs (-A) or extended attributes (-X).-v: list the files being transferred.-P: same as--partial --progress. Keeps partly transferred files so the next run can resume, and shows progress.-z: compress data in transit. Helps on slow links with compressible files; does little for photos, video or archives that are already compressed.-n/--dry-run: show what would happen without changing anything.--delete: remove files from the destination that no longer exist at the source, so the copy becomes a mirror.-e "ssh -p 2222": choose the remote shell, for example to use a different SSH port or key.
The trailing slash rule
This catches everyone once. A trailing slash on the source means "the contents of this folder"; no slash means "this folder itself".
rsync -a photos/ backup/ # backup/2026/...
rsync -a photos backup/ # backup/photos/2026/...
Real output of the second form, listing the result two levels deep:
backup2
backup2/photos
backup2/photos/2026
A slash on the destination makes no difference. If you are about to use --delete, always run once with -n first. A misplaced slash plus --delete can wipe a directory you meant to keep. Example dry-run output after deleting one source file:
$ rsync -av --delete --dry-run photos/ backup/
sending incremental file list
deleting 2026/img3.jpg
...
total size is 2,097,159 speedup is 13,189.68 (DRY RUN)
When to use which
- One file, once: scp. Nothing to install, nothing to remember.
- Copying from Windows without WSL: scp, because rsync isn't included with Windows. Inside WSL, both are available (see how to install WSL).
- Backups and deploys you repeat: rsync. Unchanged files cost almost nothing on each run.
- Large files or flaky connections:
rsync -P, so an interruption doesn't mean starting again. - Keeping a mirror in sync, including deletions:
rsync -a --delete, tested with-nfirst. - Thousands of small files once: either works; packing them first with tar or zip often beats both (see zip and unzip from the command line).
Both tools authenticate the same way SSH does, so if you are typing a password every time, set up a key once with ssh-keygen and ed25519 and both commands will stop asking.
If rsync fails on the remote side
When rsync is missing on the server, the remote shell prints its own "not found" line and rsync then reports:
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: remote command not found (code 127) at io.c(231) [sender=3.2.7]
Code 127 means rsync isn't installed on the server (or isn't on its PATH). Install it there with the system package manager (for example sudo apt install rsync on Debian or Ubuntu), or fall back to scp. If rsync connects but uses the wrong port or key, pass SSH options through -e, or put them in ~/.ssh/config under a Host entry so both scp and rsync pick them up automatically.
Frequently asked questions
- Is rsync faster than scp?
- For a first copy of new files, the two are similar because both send every byte over SSH. rsync wins on repeat copies: files with the same size and modification time are skipped, and changed files are sent as differences. For a single small file there is no practical difference.
- Can scp resume an interrupted transfer?
- No. scp has no resume option and starts each file again from the beginning. Use rsync with --partial (or -P, which also shows progress) so a broken transfer keeps the partial file and continues from it on the next run.
- Does rsync need to be installed on the server?
- Yes. The rsync manual states that rsync must be installed on both the source and destination machines. scp only needs an SSH server with SFTP enabled, which almost every SSH server has.
- Is scp deprecated?
- The old scp/rcp protocol is, but the scp command is not. Since OpenSSH 9.0 (April 2022) the scp command uses the SFTP protocol by default. The command line stays the same; -O switches back to the legacy protocol for servers that need it.
- Is rsync secure?
- When you copy to a host:path destination, rsync runs over SSH by default, so the data is encrypted and authenticated exactly like scp. Only the separate rsync daemon mode (rsync:// URLs or host::module) sends data without SSH encryption.