scp Command Builder — Linux scp Examples

Linux scp Command Builder (Secure Remote Copy)

The scp command copies files between hosts over SSH. This interactive scp Command Builder helps you generate precise scp commands for uploads and downloads.


🚀 What is the scp Command?

The scp command allows you to:

  • Copy files securely over SSH
  • Upload local files to a remote host
  • Download remote files to your local machine
  • Copy between two remote hosts
  • Preserve attributes and use custom ports and keys

⚙️ Basic Syntax

scp [options] [[user@]host1:]source_file [[user@]host2:]destination
scp [options] local_path [user@]host:path
scp [options] [user@]host:path local_path

🧠 How to Use This scp Command Builder

This tool helps you:

  • Choose copy direction (upload vs download)
  • Specify remote host, user, and path
  • Pick the correct port and identity options
  • Generate a ready-to-use scp command

Workflow

  1. Choose direction: upload or download
  2. Enter remote user, host, and path
  3. Set port, key, and extra options
  4. Copy generated command

🔧 Common scp Usage Patterns

Upload a File to a Remote Host

scp report.pdf user@192.168.1.10:/home/user/docs/

Download a File from a Remote Host

scp user@192.168.1.10:/var/log/app.log ./app.log

Use a Custom SSH Port

scp -P 2222 backup.tar.gz user@example.com:/backups/

Recursive Copy with Compression

scp -r -C ./mysite user@example.com:/var/www/

⚠️ Important Notes

  • -P vs -p is the #1 scp pitfall: use UPPERCASE -P for port, lowercase -p preserves timestamps and modes
  • Direction matters: source first, destination last; a colon means remote
  • Overwrites silently: scp overwrites the destination without asking
  • Host key checking: first connection prompts to trust the host key
  • Useful flags: -r recursive, -i identity file, -C compression, -l bandwidth limit, -o ssh options

📋 Upload vs Download

Scenario Command
Upload local to remote scp file user@host:/path/
Download remote to local scp user@host:/path/file ./
Custom port upload scp -P 2222 file user@host:/path/
Recursive directory copy scp -r dir user@host:/path/

✅ Pro Tips

  • Always double-check destination paths since overwrites are silent
  • Use -i ~/.ssh/mykey.pem when the server needs a specific key
  • Use -C for text-heavy transfers and -l 1000 to limit bandwidth
  • Test connectivity with ssh user@host before long transfers