SCP (Secure Copy Protocol) is a command-line utility for securely transferring files between Linux systems over SSH. Unlike the standard cp command which only works locally, SCP enables cross-server file operations with encryption.
Basic Command Syntax
scp [options] source_path destination_path
Commonly Used Parameters
- -r: Recursively copy directories and their contents
- -P: Specify port number (note uppercase P)
- -p: Preserve file attributes (timestamps, permissions)
- -C: Enable compression during transfer
- -v: Verbose output for debugging
- -q: Quiet mode (suppress progress output)
Practical Examples
1. Uploading Files too Remote Server
scp /local/path/file.txt user@remote_ip:/remote/path/
2. Uploading Entire Directory
scp -r /local/directory/ user@remote_ip:/remote/path/
3. Downloading Files from Remote Server
scp user@remote_ip:/remote/path/file.txt /local/path/
4. Downloading Entire Directory
scp -r user@remote_ip:/remote/directory/ /local/path/
Security Considerations
SCP uses SSH for all transfers, providing encryption for both authentication and data transfer. For additional security:
- Use SSH keys instead of password authentication
- Specify custom ports with
-Pif not using default SSH port - Consider bandwidth limits with
-lfor large transfers