The scp
(Secure Copy Protocol) command is used to securely transfer files and directories between two locations over a network. It leverages SSH (Secure Shell) for data transfer, ensuring that the data is encrypted during transmission.
The basic syntax of the scp
command is as follows:
scp [options] [source] [destination]
-r
: Recursively copy entire directories.-P port
: Specify a port number to connect to the remote host.-i identity_file
: Use the specified private key file for authentication.-v
: Enable verbose mode, providing detailed output of the transfer process.-C
: Enable compression to speed up the transfer of large files.scp localfile.txt user@remote_host:/path/to/destination/
scp user@remote_host:/path/to/remotefile.txt /local/destination/
scp -r local_directory/ user@remote_host:/path/to/destination/
scp -P 2222 localfile.txt user@remote_host:/path/to/destination/
scp -i ~/.ssh/id_rsa localfile.txt user@remote_host:/path/to/destination/
-v
option for troubleshooting if you encounter issues during file transfer.-C
option to enable compression, which can significantly reduce transfer time.