Copying files with SCP

Complete guide to using Secure Copy in Linux.

SCP (Secure Copy) is a fast, secure command-line tool for transferring files and directories between your local machine and a remote server — or even between two remote servers — over an encrypted SSH connection. It's perfect for moving backups, website files, databases, or configs on your VPS or dedicated server.

SCP uses the same authentication as SSH: password or (much better) SSH keys.

Basic syntax

scp [options] source destination
  • source — what you're copying (file or folder)
  • destination — where to put it

Either source or destination can be:

  • Local path: /home/user/backup.zip
  • Remote path: user@server-ip:/path/to/destination/

Most useful SCP options

  • -r — recursive (copy directories and all contents)
  • -P port — specify non-standard SSH port (e.g., -P 2222)
  • -p — preserve modification times, permissions, and ownership
  • -v — verbose mode (shows detailed progress and errors)
  • -C — enable compression (speeds up transfer on slow connections)
  • -i keyfile — use specific private SSH key
  • -l limit — limit bandwidth (in Kbit/s), e.g., -l 800 = ~100 KB/s

Practical examples

  1. Download a single file from server to local machine
scp user@192.168.1.100:/var/www/site.ru/wp-config.php ~/Downloads/
  1. Download file from server to local machine
scp -r user@192.168.1.100:/var/www/site.ru/uploads ~/backup/
  1. Upload a folder from local to server
scp -r ./public_html user@192.168.1.100:/home/user/
  1. Copy between two remote servers
scp -r user1@server1.example.com:/var/www/site user2@server2.example.com:/backup/
  1. Use non-standard SSH port
scp -P 2222 important.sql user@server-ip:/home/user/
  1. Use a specific SSH private key
scp -i ~/.ssh/my_special_key backup.tar.gz user@server-ip:/home/user/

Our products and services

Web HostingReliable hosting services for websites of any scale.
Order
VPSFlexible cloud infrastructure with full root access.
Order
Dedicated ServersBare metal servers for maximum performance.
Order

Quick tips for everyday use

  • Always add -r when copying directories — otherwise subfolders are ignored
  • Use -v when troubleshooting — it shows exactly where things go wrong
  • For large transfers or slow connections — add -C to enable compression
  • For resuming interrupted transfers or syncing only changes — switch to rsync (much smarter than SCP)
  • Prefer SSH keys over passwords for automation — they're far more secure and convenient
  • SCP requires a working SSH connection — if SSH fails, SCP will too

Common real-world tasks

  • Download full website files (public_html):
scp -r user@your-server:/home/user/public_html ~/local-backup/
  • Upload full website to server:
scp -r ./public_html user@your-server:/home/user/
  • Transfer a database dump:
scp mydb.sql user@your-server:/home/user/

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Need help?Our engineers will help you free of charge with any question in minutesContact us