Linux scp Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux scp Guide
Complete beginner-friendly guide to scp on Linux, covering Arch Linux, CachyOS, and other distributions including secure file copying, remote file transfer, and SSH-based file operations.
Table of Contents
scp Basics
Copy File to Server
Basic usage:
# Copy file to server
scp file.txt user@server:/path/to/destination
# Copies file to remote server
Copy File from Server
Download file:
# Copy file from server
scp user@server:/path/to/file.txt .
# Downloads file to current directory
Copying Files
With Custom Port
Non-standard port:
# Custom SSH port
scp -P 2222 file.txt user@server:/path/
# -P = port (capital P for scp)
Preserve Permissions
Keep permissions:
# Preserve permissions
scp -p file.txt user@server:/path/
# -p = preserve (keeps permissions and timestamps)
Copying Directories
Recursive Copy
Copy directory:
# Copy directory recursively
scp -r directory/ user@server:/path/
# -r = recursive (copies directory)
Verbose Mode
Show progress:
# Verbose output
scp -v file.txt user@server:/path/
# -v = verbose (shows progress)
Advanced Usage
Compression
Compress during transfer:
# Compress during transfer
scp -C file.txt user@server:/path/
# -C = compression (faster on slow connections)
Identity File
Use specific key:
# Use specific SSH key
scp -i ~/.ssh/id_ed25519 file.txt user@server:/path/
# -i = identity (SSH key file)
Troubleshooting
Permission Denied
Check SSH access:
# Test SSH connection first
ssh user@server
# Ensure SSH works before using scp
Connection Timeout
Check network:
# Test connectivity
ping server
# Verify server is reachable
Summary
This guide covered scp usage, secure file copying, and remote file transfer for Arch Linux, CachyOS, and other distributions.
Next Steps
- rsync Guide - Advanced file synchronization
- SSH Configuration - SSH setup
- ssh-keygen Guide - SSH keys
- scp Documentation:
man scp
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.