> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Copy Files to a Server with scp and rsync

> Copy a file to a server with scp: run scp file.zip alex@203.0.113.10:/home/alex/. Use rsync -avz to copy or sync whole folders and resume large transfers.

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.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 5 minutes | scp: Windows 10 / 11, macOS, Linux. rsync: macOS, Linux (both ends) | Working SSH login |

## Before you start

* You need to be able to [SSH into the server](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md). `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?

| | scp | rsync |
| - | - | - |
| Single files, quick copies | Good | Good |
| Large folders | Copies everything every time | Copies only changed files |
| Resume after a dropped connection | No | Yes, with `-P` |
| Mirror a folder (delete extras) | No | Yes, with `--delete` |
| Built into Windows | Yes | No |

Since OpenSSH 9.0, `scp` uses the SFTP protocol under the hood ([release notes](https://www.openssh.org/txt/release-9.0)), 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`.

```bash theme={null}
# Upload a file to your home folder on the server
scp backup.zip alex@203.0.113.10:/home/alex/

# Upload a whole folder
scp -r site alex@203.0.113.10:/home/alex/

# Download a file from the server into the current folder
scp alex@203.0.113.10:/home/alex/backup.zip .

# Use a custom SSH port (capital P)
scp -P 2222 backup.zip alex@203.0.113.10:/home/alex/
```

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

```bash theme={null}
# Copy the contents of ./site into /var/www/site on the server
rsync -avz ./site/ alex@203.0.113.10:/var/www/site/

# Show progress and keep partial files so a large transfer can resume
rsync -avzP backup.tar.gz alex@203.0.113.10:/home/alex/

# Use a custom SSH port
rsync -avz -e "ssh -p 2222" ./site/ alex@203.0.113.10:/var/www/site/

# Download from the server
rsync -avz alex@203.0.113.10:/var/www/site/ ./site-backup/
```

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

| Command | Result on the server |
| - | - |
| `rsync -avz site/ alex@203.0.113.10:/var/www/site/` | Files of `site` land directly in `/var/www/site/` |
| `rsync -avz site alex@203.0.113.10:/var/www/site/` | You get `/var/www/site/site/` |

### 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:

```bash theme={null}
rsync -avzn --delete ./site/ alex@203.0.113.10:/var/www/site/
```

```text theme={null}
sending incremental file list
deleting old-page.html
new-page.html

sent 124 bytes  received 37 bytes  322.00 bytes/sec
total size is 4  speedup is 0.02 (DRY RUN)
```

If the list looks right, run the same command without `n`.

> [!WARNING]
>
> `--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](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md).

## How to check it worked

List the copied files on the server and compare sizes:

```bash theme={null}
ssh alex@203.0.113.10 'ls -l /home/alex/'
```

For rsync, running the same command a second time should transfer nothing:

```text theme={null}
sending incremental file list

sent 157 bytes  received 84 bytes  482.00 bytes/sec
total size is 2  speedup is 0.01
```

## 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)](https://help.freakhosting.com/portals/other/how-to-fix-ssh-permission-denied-publickey.md)) 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](https://help.freakhosting.com/portals/other/how-to-use-ssh-config-file-shortcuts.md), `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](https://help.freakhosting.com/portals/other/how-to-back-up-a-linux-server.md) and [rsync backups](https://help.freakhosting.com/portals/other/how-to-back-up-files-with-rsync.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [SFTP, WinSCP and FileZilla](https://help.freakhosting.com/portals/other/how-to-transfer-files-with-sftp-winscp-and-filezilla.md)
>
> Drag-and-drop transfers.

> [card] [Back up files with rsync](https://help.freakhosting.com/portals/other/how-to-back-up-files-with-rsync.md)
>
> Scheduled rsync backups.

> [card] [SSH config shortcuts](https://help.freakhosting.com/portals/other/how-to-use-ssh-config-file-shortcuts.md)
>
> Shorter scp and rsync commands.

> [card] [Compress files with tar](https://help.freakhosting.com/portals/other/how-to-compress-and-extract-files-tar-zip.md)
>
> Pack a folder before copying.

***

> [!NOTE]
>
> **Checked against the official [OpenSSH scp manual](https://man.openbsd.org/scp) and [rsync manual](https://download.samba.org/pub/rsync/rsync.1)** 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.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.