How to copy files between servers
Copy files and folders between Linux servers over SSH using scp and rsync, with resumable transfers, custom ports and permission fixes.
Beginner · about 6 min · Linux, macOS, WSL
Moving a build artifact, a database dump or a log file to another machine is a daily task. Everything you need is already installed if you have SSH access: scp for one-off copies, rsync when the transfer is large, repeated or might be interrupted.
What this guide covers
- Confirm SSH access first
- Upload a single file with scp
- Download from the server
- Copy a whole directory
- Use rsync for anything large or repeated
- Non-default SSH port or key
Common pitfalls covered
- A trailing slash matters in rsync: … copies the contents, … copies the folder itself.
- If the destination needs root, copy to your home directory first, then … over SSH — sudo does not apply to the remote side of scp.
- Never paste a password into a command; set up key authentication with … instead.
Questions answered
- What is the fastest way to copy a large folder between servers?
- Can I copy files between two remote servers directly?
- How do I copy files from Windows to a Linux server?
This is a limited preview. The full walkthrough, command syntax and copy-ready examples are available to signed-in users.