scp - Secure Copy in Linux

From the Linux Essential Commands cheat sheet · Networking · verified Jul 2026

scp - Secure Copy

Copy files between local and remote machines via SSH

bash
# Copy to remote
scp file.txt username@hostname:/path/to/destination/

# Copy from remote
scp username@hostname:/path/to/file.txt ./

# Copy directory
scp -r directory/ username@hostname:/path/

# With custom port
scp -P 2222 file.txt username@hostname:/path/
✅ Uses SSH for secure file transfer
💡 -r copies directories recursively
🔍 -P (uppercase) specifies port for scp
networkscpcopyremote

More Linux tasks

Back to the full Linux Essential Commands cheat sheet