Thuta Learning
AdvancedDevOps & Toolsbeginner

scp & rsync — Sending Files to a Remote Server

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand scp & rsync — sending files to a remote server — without any of the intimidation
  • Get comfortable trying these commands yourself in the terminal
  • See how these commands are actually useful on a real server/project

Let's think about it this way for a second

scp (secure copy) runs on top of the SSH protocol and copies files between your local machine and a remote server — you upload with a pattern like scp local-file.txt user@server:/remote/path/, and download with scp user@server:/remote/file.txt . (server info goes before the :, the path goes after). scp -r copies an entire folder (the same pattern as cp -r and rm -r). rsync is a step up — it only re-copies the parts of files that have changed (delta transfer), so when you're syncing large files over and over, it's a lot faster than scp, and adding the --delete flag will also remove files at the destination that no longer exist at the source.

Let's connect it to a real scenario

If you just want to upload your website files from your local machine to a server as a one-off, scp is easy to use — scp -r ./website user@server:/var/www/mysite. If you want to keep a project folder regularly synced to a server (as part of a deploy workflow), rsync -avz ./project/ user@server:/home/user/project/ is the go-to (-a = archive mode, preserves permissions/timestamps, -v = verbose, -z = compress) — since it only sends back the small bits that changed, it can cut your deploy time way down.

Let's try it together in the terminal

bash
scp report.pdf alice@203.0.113.10:/home/alice/
scp -r ./website alice@203.0.113.10:/var/www/mysite
scp alice@203.0.113.10:/home/alice/backup.tar.gz .
rsync -avz ./project/ alice@203.0.113.10:/home/alice/project/
You should see
After running the scp command, it shows a progress percentage/speed and the file arrives at the destination.

5-minute try-it

Write out, by hand, a single command that would send a local file to a remote path using scp syntax (no need for a real server IP — just practice the syntax).

One thing to watch out for

If you run rsync --delete with the wrong destination path, it can automatically delete a large number of files on the server — before you use the --delete flag, always preview what would happen first with a dry-run (rsync --dry-run).

Easy traps

  • Leaving out the : (colon) in an scp command and mistaking it for a local path (the colon is what signals a remote path)
  • Getting confused about whether rsync's trailing slash (/) should go at the end of a folder path — behavior can differ depending on whether the trailing slash is there or not

Now try it yourself

Write out, by hand, a single command that would send a local file to a remote path using scp syntax (no need for a real server IP — just practice the syntax).

You'll know it worked when: After running the scp command, it shows a progress percentage/speed and the file arrives at the destination.

scp & rsync — Sending Files to a Remote Server | Thuta Learning