๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

๐Ÿ’ก SSH & Remote August 17, 2026 9

Linux Command: scp

Securely copy files between hosts over SSH

Terminal โ€” SSH & Remote
Command
$ scp report.pdf user@server:/home/user/Documents/

scp (secure copy) transfers files between local and remote hosts over SSH. It uses the same authentication and encryption as SSH, making it a secure alternative to FTP for file transfers. scp supports copying files in both directions: from local to remote, from remote to local, and between two remote hosts. It can copy directories recursively and preserves file permissions. While rsync is generally preferred for large transfers (it only copies changes), scp remains widely used for quick, simple file transfers because of its straightforward syntax and ubiquity on all SSH-capable systems.

Syntax

scp [OPTION]... SOURCE... DESTINATION

Key Options

  • -r โ€” Copy directories recursively
  • -P โ€” Specify SSH port
  • -i โ€” Use specific identity key
  • -C โ€” Enable compression during transfer
  • -p โ€” Preserve timestamps and permissions
  • -q โ€” Quiet mode (no progress bar)

Examples

Copy file to remote server

scp report.pdf user@server:/home/user/Documents/

Copy file from remote server

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

Copy directory recursively

scp -r ./deploy user@server:/var/www/html/

Pro Tips

  • rsync -avz is superior to scp for large directories โ€” it only transfers changed files and can resume interrupted transfers.
  • Define hosts in ~/.ssh/config, then use: scp file.txt myserver:/path/ instead of typing full user@hostname.
  • The SCP protocol has known limitations. OpenSSH 9+ uses SFTP internally for scp. For new scripts, consider using rsync or sftp directly.

Learn more: Full scp reference โ†’

Share this tip