# scp, SFTP and rsync

> Three ways to move files over SSH. scp copies once, SFTP opens a session you can browse, and rsync sends only what changed. When to use each.

**Course:** [SSH Keys and Logins](https://learn.benibix.com/learn/infrastructure-ssh)  
**Time:** 13 min

**After this lesson you can:**

- Copy a file with scp
- Browse and upload with sftp
- Sync a folder with rsync

## Which tool to use to move files

Three tools move files over SSH, and all of them use the same keys and the same locked line. scp copies files in one command, like cp across machines. SFTP opens a session where you can list folders, upload and download. rsync compares both sides and sends only what changed. For one file, use scp. For a folder you update often, use rsync.

scp reads like a copy command with an address on one side. scp report.pdf emma@203.0.113.10:/home/emma/ sends one file up. Swap the two sides to bring a file down. Add -r to copy a whole folder.

SFTP is a way to browse files on a server, built into SSH. sftp jack@203.0.113.10 opens a session. Inside it, ls lists files, put uploads one and get downloads one. Many file manager apps speak SFTP too, so you can drag and drop.

rsync is built for folders that change. The first run copies everything. After that, it compares sizes and dates on both sides and sends only the files that changed. A site of 2,000 files with 3 edits sends 3 files.

rsync -av site/ lucy@203.0.113.10:/var/www/site/ is the usual form. -a keeps dates and rights, and -v lists each file. Adding -n first shows what would be sent, with nothing sent at all.

Watch the slash at the end of the source. site/ copies what is inside the folder. site, with no slash, copies the folder itself, so you end up with /var/www/site/site.

A common mistake is rsync --delete without a dry run. It removes files on the far side that are not on yours. With the wrong path, that can be every file on the server. Run it with -n first and read the list.

## scp, SFTP and rsync side by side

|  | scp | SFTP | rsync |
| --- | --- | --- | --- |
| Works like | One copy command | A file browser | A sync of two folders |
| Sends | Everything you name | What you put or get | Only what changed |
| Best for | One file, once | Looking around, then a few files | A folder you update often |
| Dry run | No | No | Yes, with -n |

## Which one to pick

1. **Pick scp.** When you need to send or fetch one file, or one folder, once.
2. **Pick SFTP.** When you want to look around the server's folders before you choose what to move.
3. **Pick rsync.** When you send one folder up again and again, like a site after each edit.

![Three lanes, each from a laptop to a server inside the same SSH line. In the scp lane, one file is copied once, then done. In the sftp lane, a session lists, uploads and downloads. In the rsync lane, 10 files are compared, 8 are already there, 2 have changed, and only the changes travel.](https://learn.benibix.com/diagrams/inf3-file-transfer.svg)

### Example: Jack's site update

Jack's site has 1,800 files, 400 MB in all. Copying it with scp after each change takes 6 minutes.

He switches to rsync -av site/ web1:/var/www/site/. After he edits 2 pages, rsync sends just those 2 files, and the update takes 3 seconds.

**Words in this lesson:** [scp](https://learn.benibix.com/term/infrastructure/scp), [SSH File Transfer Protocol (SFTP)](https://learn.benibix.com/term/infrastructure/sftp), [rsync](https://learn.benibix.com/term/infrastructure/rsync)

> **The one difference.** scp and SFTP send what you name. rsync looks at both sides first and sends only the difference.

**Question:** You update the same 2,000-file website folder every day. Which tool fits best?

**Answer:** rsync. rsync compares both sides and sends only the files that changed. A daily update moves a few files, not all 2,000.

---

Source: https://learn.benibix.com/learn/infrastructure-ssh/scp-sftp-and-rsync
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
