CalcSnippets Search
CLI 2 min read

`scp -r` Is Still the Practical Command for Copying Project Files to or From a Server When You Need Results, Not an Overengineered Ritual

A practical guide to `scp -r` for developers who need to move directories between local and remote machines without turning a simple file transfer into a workflow science project.

Why this command matters: not every file transfer needs cloud storage, artifact pipelines, or a custom sync story. Sometimes you just need the directory moved.

Developers regularly overcomplicate simple transfer work. A few logs need pulling from a server. A build artifact needs copying to a VM. A configuration directory needs to move to a remote box. This is exactly the sort of thing scp -r handles well.

The core command

Copy a local directory to a server:

scp -r ./dist [email protected]:/var/www/my-app/

Copy a remote directory to your machine:

scp -r [email protected]:/var/log/my-app ./logs

The -r means recursive, which is what makes directory copies work.

Why people still get it wrong

The most common mistakes are not conceptual. They are path mistakes:

  1. copying to the wrong remote directory
  2. forgetting whether the trailing slash changes intent
  3. using the wrong username or host alias
  4. assuming scp preserves everything like a deployment tool would

That is why it helps to test the target path with a quick SSH session first:

ssh [email protected]
pwd
ls -la /var/www/my-app

Now you know where the copy is landing instead of hoping the path in your head matches the machine.

Good use cases

scp -r is especially useful for:

  1. copying logs from a remote machine
  2. shipping a build artifact to a server
  3. moving config or backup directories
  4. grabbing a quick repro dataset from a box you control

It is not the best tool for large-scale incremental sync. That is where rsync often wins. But for one-shot recursive copies, scp -r is still practical and direct.

Useful variations

Specify a non-default SSH key:

scp -i ~/.ssh/my_key -r ./dist [email protected]:/var/www/my-app/

Use a custom port:

scp -P 2222 -r ./dist [email protected]:/var/www/my-app/

These details matter when the server setup is not vanilla.

Final recommendation

If you just need to move a directory to or from a machine you can SSH into, scp -r is still one of the cleanest tools available. Keep the paths precise, verify the destination, and avoid turning a basic transfer into unnecessary ceremony.

Sources

Keep reading

Related guides