Skip to main content
To copy a file to a server, run scp backup.zip alex@203.0.113.10:/home/alex/ on your own computer. Add -r for a folder and -P 2222 for a custom SSH port. For large folders or repeated copies use rsync -avz ./site/ alex@203.0.113.10:/var/www/site/, which only sends what changed and can resume. Both use your normal SSH login.

Before you start

  • You need to be able to SSH into the server. scp and rsync use the same user, port and key.
  • Run the commands on your own computer, not inside an SSH session, unless you are copying between two servers.
  • rsync must be installed on both machines: sudo apt install rsync (Ubuntu/Debian) or sudo dnf install rsync (AlmaLinux/Rocky).

Should I use scp or rsync?

Since OpenSSH 9.0, scp uses the SFTP protocol under the hood (release notes), so it works anywhere SFTP works.

How to copy files with scp

The pattern is scp <from> <to>. A remote location is written user@host:path.
On Windows, write local paths the Windows way, for example scp C:\Users\alex\Downloads\backup.zip alex@203.0.113.10:/home/alex/.

How to copy and sync folders with rsync

What the options mean: -a keeps permissions, times and folder structure, -v lists files, -z compresses during transfer, -P shows progress and keeps partial files.

The trailing slash matters

How to mirror a folder safely

--delete removes files on the destination that no longer exist in the source. Always run it with --dry-run (-n) first and read the list:
If the list looks right, run the same command without n.
--delete with the wrong path (for example a missing trailing slash, or source and destination swapped) can wipe a folder on the server. Use --dry-run first and keep a backup.

How to check it worked

List the copied files on the server and compare sizes:
For rsync, running the same command a second time should transfer nothing:

Frequently asked questions

Can I copy files directly between two servers?

Yes. Log in to one server and run scp or rsync there with the other server as the destination. The first server needs a login (password or key) for the second.

Why does scp say “Permission denied”?

Either the login failed (see permission denied (publickey)) or your user can’t write to the target folder. Copy to your home folder first, then move the file with sudo over SSH.

Can I use an SSH config alias with scp and rsync?

Yes. With a Host web entry in your SSH config, scp backup.zip web: and rsync -avz site/ web:/var/www/site/ work.

Is rsync a backup?

It copies files, which is a start. For versioned, encrypted backups see how to back up a Linux server and rsync backups.

VPS and dedicated server guides

Every guide in this section.

SFTP, WinSCP and FileZilla

Drag-and-drop transfers.

Back up files with rsync

Scheduled rsync backups.

SSH config shortcuts

Shorter scp and rsync commands.

Compress files with tar

Pack a folder before copying.

Checked against the official OpenSSH scp manual and rsync manual on 4 November 2026; all scp and rsync commands, including --dry-run --delete, were tested with OpenSSH 9.6 and rsync 3.2.7 on Ubuntu 24.04 LTS.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026