DEV Community

Svyatoslav Pavlov
Svyatoslav Pavlov

Posted on Originally published at termal.in on

How to move files between two servers — without downloading them to your laptop first

scp -3, rsync, the tar-over-ssh pipe, S3 as a relay, and the GUI way: five ways to copy files server-to-server, and when each one wins.

You have a 40 GB directory on server A that needs to be on server B. The reflex — download to the laptop, upload to the other box — moves the data twice, hammers your home uplink in both directions, and falls over the moment your Wi-Fi hiccups at gigabyte 32. Every admin eventually collects a better toolkit for this. Here it is, shortest path first.

1. scp -3 — the honest middleman

scp -3 -r alice@server-a:/srv/app/data bob@server-b:/srv/app/
Enter fullscreen mode Exit fullscreen mode

The -3 routes traffic through your machine — A sends to you, you forward to B, nothing is written to disk. Both sides authenticate with your local keys, which is exactly why this is the zero-setup option: A and B never need to trust each other.

The cost: every byte still crosses your connection twice (in and out), and scp has no resume. Fine for config directories and dumps in the single-gigabyte range; wrong tool for the 40 GB case unless your uplink is excellent.

2. Direct copy: run it on one of the servers

The fast path is A talking straight to B over their (usually much fatter) link:

ssh alice@server-a
rsync -avP /srv/app/data bob@server-b:/srv/app/
Enter fullscreen mode Exit fullscreen mode

rsync -avP gives you progress, permissions, and — the killer feature — resume: re-run the same command after any interruption and it continues where it stopped, skipping what already matches.

The catch is auth: A now needs to authenticate to B. Resist the classic shortcut of copying your private key onto A. The cleaner options, best first:

  • A dedicated key pair on A, authorized on B for exactly this job — ideally with a command= restriction in B's authorized_keys limiting it to rsync.
  • Agent forwarding (ssh -A alice@server-a) — your local agent answers B's challenge, no key material lands on A. Use it only toward servers you'd trust with your agent: root on A can borrow your agent socket while you're connected.

3. The tar pipe — for minimal boxes

Appliance-grade hosts sometimes lack rsync. tar and ssh are always there:

ssh alice@server-a 'tar cf - -C /srv/app data' | ssh bob@server-b 'tar xf - -C /srv/app'
Enter fullscreen mode Exit fullscreen mode

Streams through your machine like scp -3, but preserves permissions and symlinks faithfully, handles a million small files far better than per-file scp, and composes with zstd (tar cf - … | zstd / zstd -d | tar xf -) when the pipe is thin. No resume — it's the duct-tape option, and everyone should know it anyway.

4. Object storage as the relay

When the two servers can't reach each other and the data is big, stop streaming and stage it once in a bucket:

# on A                                   # on B
aws s3 cp data s3://my-bucket/xfer/ -r    aws s3 cp s3://my-bucket/xfer/ data -r
Enter fullscreen mode Exit fullscreen mode

Both directions use each server's own (fat) link, either side can resume, and the bucket doubles as an audit point. Works with any S3-compatible storage — MinIO on your own hardware counts. Just remember the lifecycle rule so xfer/ doesn't quietly become a 400 GB monument to one migration.

5. The GUI way — two panes, two servers

For the everyday version of this problem — a handful of files, two servers, no ceremony — a dual-pane file manager beats all of the above on time-to-done. In Termalin, each pane connects independently: local↔host, host↔host, or an S3 bucket as either side. Drag from pane to pane and the app does the download-then-upload for you, through a temporary file on your machine that it deletes afterwards. So the bytes do pass through your connection, which is fine for a handful of files; for the 40 GB directory, use one of the server-side options above. Auth is whatever each host already uses in your client, so there's no key-copying question at all, and no agent to expose.

It's also the option you can hand to a teammate who would rather not learn the authorized_keys command= syntax before lunch.

Which one, when

Situation Reach for
Small transfer, zero setup, untrusting servers scp -3
Big transfer, servers can talk, needs resume rsync run on A
Minimal/appliance hosts, lots of small files tar-over-ssh pipe
Servers can't reach each other, huge data S3 relay
A few files, done in ten seconds dual-pane GUI

The theme across the first four: the data should cross each network segment once, and your laptop should be a controller, not a warehouse. The GUI trades that for convenience, which is why it's the small-files answer.


Termalin's dual-pane file manager does local↔host and host↔host transfers in the Free tier (an S3 bucket as a pane is on Pro) — download it, or browse the full feature list.

Top comments (0)