The scp
(secure copy) command is used to securely transfer files and directories between two hosts over a network. It utilizes SSH (Secure Shell) for data transfer, ensuring that the data is encrypted during the process.
The basic syntax of the scp
command is as follows:
scp [options] [source] [destination]
-r
: Recursively copy entire directories.-P port
: Specify the port to connect to on the remote host.-i identity_file
: Select the file from which the identity (private key) for public key authentication is read.-v
: Enable verbose mode, which provides detailed information about the transfer process.scp localfile.txt user@remotehost:/path/to/destination/
scp user@remotehost:/path/to/remotefile.txt /local/destination/
scp -r localdirectory/ user@remotehost:/path/to/destination/
scp -P 2222 localfile.txt user@remotehost:/path/to/destination/
scp -i ~/.ssh/id_rsa localfile.txt user@remotehost:/path/to/destination/
scp
.-v
option for troubleshooting if you encounter issues during file transfer.rsync
for better performance and resuming capabilities.