Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

23 October 2026 · One command a day

How do I copy a file to or from a server with scp?

The scp command copies a file between your computer and a server over SSH. Use it when you need to move one file, such as a backup archive or a config file, and do not want to set up anything else. If you can log in with SSH, scp already works.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

scp file.tar.gz user@host:/path/

scp stands for secure copy. It uses the same login and keys as SSH. file.tar.gz is the local file you want to send. user@host is the account and server address, the same as you would type after ssh. The colon separates the server from the path. /path/ is the folder on the server where the file will land, and the trailing slash makes it clear that you mean a directory. To copy the other way, swap the order. scp user@host:/path/file.tar.gz . downloads the file into your current folder.

What you will see

file.tar.gz                                100%   48MB  11.6MB/s   00:04

scp prints one line per file. While the copy runs, the percentage, amount transferred, speed and estimated time remaining update in place. When the line reaches 100% and you are back at the prompt, the copy is complete. If no progress line appears and the command finishes straight away without an error, check whether you left out the colon. If you see Permission denied, the user you logged in as cannot write to that folder on the server.

When to use it

Watch out for

Forgetting the colon is the most common mistake. scp file.tar.gz user@host does not touch the server at all. It creates a local copy called user@host in your current folder and reports success. Always include the colon, even when you want the file in your home folder on the server. user@host: on its own means that home folder. Also note that scp overwrites a file with the same name at the destination without asking.

Questions people ask

How do I use scp with a different SSH port?

Use a capital -P, as in scp -P 2222 file.tar.gz user@host:/path/. A lowercase -p does something else in scp: it keeps the file's original modification times and permissions.

Can scp copy a whole folder?

Yes, add -r to copy the folder and everything in it. For large folders or repeated copies, rsync is a better fit, because it only sends what has changed.

Copying files straight onto a server's disk is the kind of thing you can only do on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I back up a MySQL database from the command line? · How do I back up a Postgres database from the command line? · How do I copy a folder to another server with rsync? · All daily notes