December 4, 2026

scp vs rsync vs sftp: The Same 50 MB File, Copied Three Ways and Then Changed by 1,000 Bytes

A van, a box truck and a cargo bike parked side by side at a loading dock

All three tools copy files over SSH, use the same keys and the same port, and on a fast link the first copy takes about the same time with each. The difference shows up on the second copy, on a file name with a space in it, and on a copy that dies halfway. The tests below used OpenSSH 9.6 and rsync 3.2.7 on Ubuntu 24.04, copying to a second SSH server on the same machine, so the network was out of the picture and only the tools’ behavior was measured.

Video: Learn Linux TV on YouTube

The test

One folder, three files

The source directory held a 50,000,000-byte file of random data, a small text file with a modification date set back to January 2, 2026, and a subdirectory with one more small file. Each tool copied it to a fresh destination over SSH on port 2222.

First copy: a tie

Tool Time for the first full copy
scp -r 0.48 s
rsync -a 0.40 s

On the first copy every byte has to move, and every tool moves it the same way, through an encrypted SSH channel. On a real network the link speed would dominate both numbers. Choosing between these tools on speed alone, for a first copy, is choosing between equals.

Page of printed text from a book

scp: simple, and newer than it looks

It uses SFTP now

Old documentation says scp uses its own legacy protocol. That stopped being true by default with OpenSSH 9.0. The release notes from April 8, 2022 state that the release switches scp(1) from using the legacy scp/rcp protocol to using the SFTP protocol by default.

The reason given is quoting. With the legacy protocol, wildcards in remote file names were expanded by the remote shell, so shell characters had to be quoted twice. The notes describe SFTP mode as no longer needing that “finicky and brittle quoting.” The old protocol is still available with -O.

The space-in-the-name test

A file called my file.txt on the remote side, copied back with the remote path in ordinary quotes:

$ scp "root@127.0.0.1:/tmp/xf/src/my file.txt" dst2/
(copied)

$ scp -O "root@127.0.0.1:/tmp/xf/src/my file.txt" dst2/x.txt
scp: /tmp/xf/src/my: No such file or directory
scp: file.txt: No such file or directory

The modern default handled it. The legacy protocol handed the path to the remote shell, which split it at the space and looked for two files. That is the “finicky and brittle quoting” in one example.

What scp does not keep by default

After the scp -r copy, the small text file’s date had changed:

2026-01-02 03:04:05  src/a.txt
2026-11-30 22:34:34  dst1/src/a.txt

The copy carried the time it was made, not the original’s. scp -p kept the original 2026-01-02 03:04:05. For backups or anything that later compares dates, that flag matters.

rsync: the second copy is where it wins

Nothing changed

Running the identical rsync -a command a second time, with nothing changed on either side:

Number of regular files transferred: 0
Literal data: 0 bytes
Total bytes sent: 135

135 bytes, the file list and nothing else. The rsync manual explains why: by default it uses a “quick check” that looks for files that have changed in size or in last-modified time, and skips the rest.

scp has no such check. Asked to copy the same folder again, it copies every byte again.

1,000 bytes changed in a 50 MB file

Then 1,000 bytes in the middle of the large file were overwritten, and rsync ran again:

Number of regular files transferred: 1
Literal data: 7,064 bytes
Matched data: 49,992,936 bytes
Total bytes sent: 35,563

rsync sent about 35 KB to update a 50 MB file. The manual describes this as its delta-transfer algorithm, sending only the differences between the source and the file already at the destination. Of the 50,000,012 bytes, 49,992,936 were matched against blocks the destination already had, and only about 7 KB of new data went across. cmp confirmed the two files were identical afterwards.

scp copied the whole 50 MB file again for the same 1,000-byte change. On a fast local link the time was similar. Over a slow uplink, or for a nightly copy of a large database dump or VM image, the gap is the entire file.

The trailing slash

rsync has one rule that surprises everyone once. The manual states that a trailing slash on the source changes this behavior to avoid creating an additional directory level. Two otherwise identical commands:

rsync -a src  host:dst3/noslash/    →  dst3/noslash/src/a.txt
rsync -a src/ host:dst3/slash/      →  dst3/slash/a.txt

Without the slash, the directory itself is copied into the destination. With it, only the contents are. A backup script that adds or loses one slash ends up with a nested src/src/ folder, or files spread where a folder was expected.

Archive mode and the safe deletion habit

-a is the flag almost every rsync command uses. The manual defines it as equivalent to -rlptgoD: recursive, and preserving symlinks, permissions, times, group, owner and device files. It is why rsync kept the original dates without being asked.

--delete removes files from the destination that no longer exist at the source, which turns a copy into a mirror and is the one rsync option that destroys data. Paired with -n, a dry run, it reports first:

$ rsync -a -n --delete -v src/ host:dst3/slash/
deleting sub/b.txt
sub/

Nothing was deleted. The list said exactly what would be.

Stacked cardboard boxes

sftp: interactive and scriptable

A file-manager session over SSH

sftp opens a session with commands like ls, get, put, cd and rm. Fed a batch file with -b, it also runs unattended:

sftp> ls -l
-rw-r--r--    ? root  root        6 Jan  2  2026 a.txt
-rw-r--r--    ? root  root 50000000 Nov 30 22:34 big.bin
drwxr-xr-x    ? root  root     4096 Nov 30 22:34 sub
sftp> get a.txt got.txt

Its strength is the case the other two do not cover well: browsing a remote directory to find what to copy, or working with a server that offers SFTP but no shell at all. Hosting providers and NAS devices often allow SFTP-only accounts, where rsync, which needs to run a program on the far side, cannot work.

Which one

Situation Tool
One file, once scp (add -p to keep dates)
A folder that will be copied again later rsync -a
Large files that change a little each time rsync -a
Keeping a mirror, including deletions rsync -a --delete, run with -n first
Unknown remote layout, browsing first sftp
SFTP-only account, no shell sftp (or scp, which now speaks SFTP)
Solid-state drive

When a copy dies halfway

The test

A 20,000,000-byte file was sent with a bandwidth limit and cut off after two seconds with timeout, three ways:

Command Left at the destination
rsync -a Nothing
rsync -a --partial 7,667,712 bytes of big.bin
scp -l 32000 7,572,480 bytes of big.bin

Plain rsync writes to a hidden temporary file and removes it when interrupted, so a failed copy never leaves a half-file that looks complete. With --partial, which the manual summarizes as “keep partially transferred files,” the partial data stays. -P is shorthand for --partial --progress.

Resuming

Running the --partial copy again finished the job:

Literal data: 12,332,640 bytes
Matched data: 7,667,360 bytes

The 7.7 MB already at the destination was matched and reused, and only the remaining 12.3 MB crossed the link. On a connection that drops every few minutes, that is the difference between a copy that eventually finishes and one that never does. scp also left a partial file behind, 7.5 MB of it under the full name, which is worse than nothing: a later check by file name alone would find big.bin present. scp has no option to resume it, so the next run sends all 20 MB again.

sftp, oddly, does better than scp here, although both now speak the same protocol. Its reget command continues a download from the size of the local file. Given a 5,000,000-byte local fragment of the 20 MB file, a batch run of reget big.bin finished the download, and cmp confirmed the result was identical to the original. reput does the same for uploads.

Compression

-z compresses data on the way. It helps exactly as much as the data compresses:

File Size Bytes sent, rsync -a Bytes sent, rsync -az
3 million lines of numbers 22,888,896 22,894,582 946,094
20 MB of random data 20,000,000 (not run) 20,004,629

Text shrank to about 4 percent of its size on the wire. Random data, which stands in for photos, video and already-compressed archives, did not shrink at all, and paid the compression cost for nothing.

Sources## Sources

  • OpenSSH 9.0 release notes, April 8, 2022: https://www.openssh.org/txt/release-9.0
  • rsync(1) manual page, samba.org: https://download.samba.org/pub/rsync/rsync.1

663 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *