SFTP and rsync both copy files to a server over SSH, but they solve different problems. SFTP is enough to upload or download individual files and browse directories. rsync -avz -e ssh is the right tool for syncing whole folders repeatedly, because it sends only what changed, and with --delete it also mirrors removals on the destination.
SFTP and rsync: what each one does when copying files over SSH
SFTP is an SSH subsystem: it runs over the same connection, on TCP port 22 by default, and authenticates with the same keys. It gives you an interactive session with commands such as put, get, ls and rename, and it copies every file in full. Since OpenSSH 9.0 (April 2022), scp also uses the SFTP protocol by default, so both share the same foundation.
rsync is a different tool: it compares source and destination and sends only the differences. With -e ssh it opens an SSH connection and starts rsync on the server, so it needs rsync installed on both ends. SFTP only needs the SSH server to have the SFTP subsystem enabled.
SFTP vs rsync comparison table for copying files
SFTP resends every file in full on each copy; rsync sends only what changed since the last sync. The remaining differences look like this:
| Criterion | SFTP | rsync -avz -e ssh |
|---|---|---|
| What gets transferred | Whole files | Only differences between source and destination |
| Server requirement | SFTP subsystem of the SSH server | rsync installed on both ends |
| Interactive use | Yes: browse, list, rename, delete | No: one command per sync |
| Mirroring deletions | No, delete by hand | Yes, with --delete |
| Resuming transfers | reget and reput | --partial, included in -P |
| Keeping permissions and times | put -p and get -p | -a (archive mode) |
| From a phone | SFTP browser built into the client | Runs on a server from the SSH session |
rsync -avz -e ssh: base command and what each flag does
The base command to copy a local folder to a server with rsync over SSH is rsync -avz -e ssh source/ user@server:destination/. These are the most common variants:
# Base copy
rsync -avz -e ssh ./web/ user@server:/var/www/web/
# SSH port other than 22
rsync -avz -e "ssh -p 2222" ./web/ user@server:/var/www/web/
# With progress and partial-file resume
rsync -avzP -e ssh ./backups/ user@server:/srv/backups/- -a: archive mode. Recursive copy that keeps permissions, timestamps and symlinks; owner and group only when run with privileges.
- -v: lists the files being transferred.
- -z: compresses data in transit. Helps on slow links; adds little for already compressed files.
- -e ssh: sets SSH as the transport and lets you pass it options, such as the port.
- -P: same as
--partial --progress; keeps what was already sent if the connection drops.
The trailing slash on the source changes the result: ./web/ copies the folder's contents, while ./web creates a web directory inside the destination.
rsync --delete: how to mirror deletions without losing server files
The --delete option removes files on the destination that no longer exist on the source, leaving the server as an exact copy. It is the flag that turns a copy into a mirror, so always rehearse it with -n (--dry-run) first:
# Dry run: lists what would be copied and what would be deleted
rsync -avzn --delete -e ssh ./web/ user@server:/var/www/web/
# Real run, protecting files that only exist on the server
rsync -avz --delete --exclude 'uploads/' -e ssh ./web/ user@server:/var/www/web/Files excluded with --exclude are not deleted on the destination unless you add --delete-excluded. These four mistakes with rsync --delete cost the most data:
- Targeting the parent directory. Syncing
./web/to/var/www/deletes everything in/var/wwwthat is not inweb. - Skipping the dry run. Without
-n, you find out what was deleted afterwards, not before. - Swapping source and destination. With the server as the source,
--deleteremoves files from your local copy. - Not excluding server-generated files. User uploads, caches or a server-only
.envdisappear unless excluded.
When SFTP is enough to copy files to the server
SFTP is enough when the job is a one-off: uploading a config file, downloading a log, or checking a directory before touching it. It does not need rsync on the server, and the interactive session lets you verify every step:
sftp user@server
sftp> cd /etc/nginx/sites-available
sftp> get default default.bak
sftp> put default
sftp> put -r certs
sftp> reget backup.tar.gz
sftp> byeSFTP is also the only option on accounts restricted with ForceCommand internal-sftp, where rsync cannot start its remote process. Every available command is listed in the official OpenSSH sftp manual. If the task repeats daily or touches hundreds of files, rsync saves time and mistakes.
SFTP and rsync from your phone with termi1
termi1 has built-in SFTP to view, upload and download files without leaving the SSH session, which is exactly the case where SFTP is enough. For rsync, the usual approach on a phone is to connect to a server and run the sync from there to another machine.
- Long sessions: termi1 keeps the session alive with Mosh when switching from wifi to mobile data and uses tmux, so an rsync started inside tmux keeps running when you come back.
- Keyboard: termi1's own keyboard includes Ctrl, Esc, Tab and arrow keys to cancel with Ctrl+C or complete paths with Tab.
- AI that never presses Enter for risky commands: describe the copy in a sentence and the AI types the command at the prompt. On connections tagged as production, nothing gets Enter automatically and anything that deletes is held back.
- Keys: generated on the phone; the private key never leaves the device.
The termi1 SSH and SFTP terminal works without an account and is free; you can download termi1 for iPhone or find it on Google Play.
Frequently asked questions
Does rsync work over SFTP?
rsync does not use the SFTP protocol: it uses SSH as a transport and starts its own rsync process on the server. That is why it needs rsync installed on both ends and fails on accounts restricted to internal-sftp, where only SFTP is available.
What exactly does rsync --delete do?
rsync --delete removes files on the destination that do not exist on the source, leaving an exact copy. Run it first with -n to see the list of deletions, and protect server-only files with --exclude before running it for real.
Is scp or SFTP better for copying files?
scp and SFTP share the same protocol in modern OpenSSH, because since OpenSSH 9.0 scp uses SFTP by default. scp suits a quick one-line copy; SFTP adds an interactive session to browse, rename and resume downloads with reget.
Can you use rsync from a phone?
rsync can be used from a phone by opening an SSH session on a server and running it there. Starting it inside tmux keeps a long sync from being interrupted if the network changes or the app is closed.