How to use the SCP and rsync Command Builder
- Choose upload or download and type the local and remote paths.
- Enter the server, user, SSH port and key.
- Pick the rsync options: archive, compress, excludes, dry run, and --delete only if you mean to mirror.
- Read the trailing-slash line, then copy the rsync or scp command and run it in your terminal.
scp or rsync: which one copies files to a server?
Both copy files over SSH. scp copies everything you name, every time, and is installed wherever the OpenSSH client is, Windows included. rsync compares both sides and sends only what changed, can resume, exclude and delete, and has a dry run, so it is the better tool for deploying a folder or keeping a backup in step.
scp -r ./dist deploy@203.0.113.10:/var/www/app/
rsync -az --progress ./dist/ deploy@203.0.113.10:/var/www/app/The trailing slash in rsync
rsync treats the source path differently depending on its last character:
| Command | Result |
|---|---|
rsync -a dist/ server:/var/www/app/ | the contents of dist: /var/www/app/index.html |
rsync -a dist server:/var/www/app/ | the folder itself: /var/www/app/dist/index.html |
A slash on the destination makes no difference. scp ignores a trailing slash on the source: scp -r dist/ server:/srv/x copies the folder into /srv/x/dist when /srv/x exists, and makes /srv/x a copy of it when it does not. The builder spells out what your exact paths will do.
The options
-aarchive: recursive, and keeps times, permissions, symlinks, owner and group. scp's nearest is-r -p.-zcompress in transit (scp-C). Worth it on slow links; skip it for already-compressed files.-ndry run: list what would change and change nothing.-Pis--partial --progress: show progress and keep partly sent files so a rerun resumes.--exclude=PATTERN, one per pattern, relative to the source:node_modules,.git,*.log.--bwlimit=RATEin KiB per second. scp's-ltakes Kbit/s, so 1000 KiB/s is-l 8192.--deleteremoves files on the destination that are not in the source.
Ports, keys and quoting
rsync takes the SSH port and key through -e: rsync -a -e 'ssh -p 2222 -i ~/.ssh/deploy' dist/ deploy@host:/srv/app/. scp takes them directly, with a capital P: scp -P 2222 -i ~/.ssh/deploy. An alias from ~/.ssh/config covers both.
A path with spaces or shell characters passes through more than one parser. The builder handles each:
- Your shell. Every value is single-quoted, and a single quote inside it is written
'\''. A leading~/stays outside the quotes so the shell still expands it, and*and?stay outside too so wildcards still work. - scp and rsync themselves. A local path with a colon before its first slash, such as
a:b.txt, would be read as a host, and one starting with-as an option, so both get./in front. - The remote shell. scp from OpenSSH 9.0 on uses the SFTP protocol, which never passes the remote path through a shell. Legacy scp (
-O) does, so the builder quotes the remote path a second time and adds-Tto downloads, because the names the server sends back then differ from what scp asked for. rsync 3.2.4 and later escape remote paths by themselves;-s(--secluded-args, formerly--protect-args) keeps older versions from splitting them.
Each of these was checked by running the generated commands against a real OpenSSH 9.6 server with a path containing spaces, quotes, $( ), backticks, ;, &, | and non-ASCII letters.
Windows
The OpenSSH client built into Windows 10 and 11 includes scp, and Windows paths such as C:\Users\you\file work with it. PowerShell reads single quotes as this builder writes them, except that it doubles a quote inside quotes ('') instead of '\''. Check the version with ssh -V: Windows 10 often has OpenSSH 8.1, whose scp always uses the legacy protocol and has no -O flag, so a remote path with spaces needs the double quoting shown under Legacy, without -O. rsync has no native Windows build in OpenSSH: run it in WSL, where C:\Users\you is /mnt/c/Users/you. The builder converts a Windows path for the rsync command.
Common errors and how to fix them
- rsync: command not found on the remote side. rsync must be installed on both ends:
sudo apt install rsync. - Permission denied (publickey). The key or user is wrong; test with
ssh -i key -p port user@hostfirst. - scp: dest open "...": Failure. The destination folder does not exist. scp does not create it for a single file; rsync creates the last folder of the path.
- protocol error: filename does not match request. Legacy scp with a quoted or wildcard remote path; add
-T, or drop-O. - Files land one folder too deep, or spill into the parent. The trailing slash; see the table above.
Shipown's file manager
For one-off copies without a terminal, Shipown's file manager browses a server over SSH, uploads single files or a whole folder tree with its structure kept, shows each transfer's percentage, and downloads, renames and edits files in place.
Frequently asked questions
What does the trailing slash do in rsync?
A slash at the end of the source copies what is inside the folder; without it, rsync copies the folder itself into the destination. A slash on the destination makes no difference.
How do I use rsync with a different SSH port?
Pass it through -e: rsync -a -e 'ssh -p 2222' src/ user@host:/dest/. Add -i and a key path inside the same quotes to choose the key.
Is rsync faster than scp?
For a second copy, yes: rsync sends only files that changed, and only the changed parts of large files. For a single first copy they move the same bytes.
How do I copy a path with spaces using scp?
Quote the whole argument: scp file 'user@host:/srv/my dir/'. OpenSSH 9.0 and later send it over SFTP, so one level of quoting is enough; legacy scp -O needs the remote path quoted again.
Is rsync --delete safe?
It does exactly what it says: it deletes files in the destination that are not in the source. Run it with -n (dry run) first and check the destination path and the trailing slash.
Can I use rsync on Windows?
Not with the built-in OpenSSH, which has scp but no rsync. Use rsync inside WSL, where your C: drive is /mnt/c.