back

SCP Basics

SCP (Secure Copy) is a command-line tool for securely transferring files over SSH between local and remote systems.

Basic Syntax

Use scp [options] source destination where source and destination follow [user@]host:path. Local to remote: Copies files from your machine to a server. scp file.txt user@remotehost:/path/to/dest/

Remote to local: Downloads files from a server. scp user@remotehost:/path/to/file.txt ./localfile.txt

Common Options

  • -r: Recursive copy for directories.
  • -P port: Specify SSH port (uppercase P).
  • -i keyfile: Use private key for authentication.
  • -C: Compress data for faster transfers.
  • -v: Verbose output for debugging.
  • -q: Quiet mode, suppress progress.
  • -l limit: Bandwidth limit in Kbit/s (e.g., -l 800).
  • -p: Preserve file timestamps and modes.

Transfer Examples

Single file upload:
scp /local/file.txt user@192.168.1.100:/home/user/docs/

Download directory recursively:
scp -r user@remotehost:/remote/dir/ ./local_dir/

Multiple files to remote: scp file1.txt file2.txt user@host:/path/

With custom port and key: scp -P 2222 -i ~/.ssh/id_rsa -C localfile.zip user@host:/dest/

Remote to remote (via local):
scp user1@host1:/file.txt user2@host2:/dest/

more resource- https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/
https://www.howtogeek.com/804179/scp-command-linux/
https://www.geeksforgeeks.org/linux-unix/scp-command-in-linux-with-examples/

Copyright © 2026 Mahidul Haque. This post is licensed under a CC BY-NC-ND 4.0 license. You may read, learn, and share links to this post for non‑commercial, educational purposes, as long as you give appropriate attribution. You may not copy, reproduce, adapt, distribute, or use this work commercially without explicit permission.