How to Transfer Files to a Linux Server (scp, sftp, rsync and WinSCP)

If you can SSH to the server, you can copy files to it — no extra setup, nothing to install, everything encrypted. There are three ways, and which you pick depends on whether it's one file, a whole folder, or you'd just rather have a window to drag things into.
Quick reference
| Task | Command |
|---|---|
| Copy a file to the server | scp file.txt john@192.168.1.50:~/ |
| Copy a file from the server | scp john@192.168.1.50:~/file.txt . |
| Copy a folder | scp -r photos john@192.168.1.50:~/ |
| Sync a folder (only changes) | rsync -avz photos/ john@192.168.1.50:~/photos/ |
| Drag and drop | WinSCP (Windows), FileZilla or Cyberduck (Mac) |
1. scp — one file, one command
scp report.pdf john@192.168.1.50:~/
That's scp source destination. The server side is user@address:path. ~/ is the user's home folder; use /var/www/html/ or any other path instead.
To pull a file the other way, swap them:
scp john@192.168.1.50:/var/log/nginx/error.log .
The . means "here, in my current folder". Add -r for folders. If you set up a nickname in your SSH config (tutorial 2), scp report.pdf home:~/ works too.
2. rsync — folders, and only what changed
scp copies everything every time. rsync compares and only sends what's new or changed, so the second run of a 50 GB photo folder takes seconds.
rsync -avz --progress photos/ john@192.168.1.50:~/photos/
- -a keeps dates and permissions, -v shows what it's doing, -z compresses.
- The trailing slash matters. photos/ means "the contents of photos"; photos means "the folder itself", so you'd end up with ~/photos/photos.
- Add --delete to remove files on the server that you've deleted locally — this turns it into a proper mirror. Test with --dry-run first.
On Windows, rsync comes with Git Bash or WSL, or use WinSCP's sync feature.
3. sftp — a file-transfer prompt
sftp john@192.168.1.50
Then ls, cd to move around the server; lls, lcd for your own computer; put file to upload; get file to download; exit to leave. Useful when you want to look around before copying.
4. Drag and drop
- Windows: WinSCP. Enter the address, username and password (or point it at your key), and you get a two-pane window.
- Mac: Cyberduck or FileZilla. Choose SFTP as the protocol.
They use the same SSH login, so nothing needs installing on the server. Both can also open a server file in your usual editor and upload it when you save.
Files that need root
You can't scp straight into /etc because your user can't write there. Copy to your home folder first, then move it:
scp nginx.conf home:~/
ssh home "sudo mv ~/nginx.conf /etc/nginx/nginx.conf"
Troubleshooting
"Permission denied" at the destination. The folder belongs to another user (often www-data). Copy to ~/ and sudo mv, or sudo chown the folder.
"No such file or directory." The path on the server doesn't exist. ssh home "mkdir -p ~/photos" first, or check for a typo.
Transfer is slow on a local network. Encryption is the bottleneck on an old CPU. Add -c aes128-gcm@openssh.com to scp, or use rsync, which is faster for many small files.
WinSCP says the host key is unknown. Normal on first connection. Click Yes if you trust the server.
Wrapping up
scp for a quick file, rsync -avz for folders you'll copy more than once, WinSCP or Cyberduck when you'd rather see what you're doing. All of them ride on the SSH login you already have.
