Secure Copy (SCP) is a network protocol used to securely transfer files between a local and a remote system, or between two remote systems, over an encrypted SSH connection. It ensures data integrity and confidentiality during the transfer by encrypting the files and authentication details.
scp file.txt root@192.168.1.34:/root/scp ftp-server.py root@192.168.1.31:/tmp/Explanation:
- Copies
file.txtandftp-server.pyfrom the local system to the specified remote directories (/root/,/tmp/).
scp file1.txt file2.txt root@192.168.1.34:/home/root/scp image.png notes.md root@192.168.1.100:/var/www/html/Explanation:
- Transfers multiple files (
file1.txt,file2.txt,image.png,notes.md) to the specified directory on the remote server.
๐ธ To recursively copy an entire directory and its contents from the local system to the remote system:
scp -r /local/dir root@192.168.1.34:/remote/dirscp -r ~/Downloads root@192.168.1.34:/tmp/Explanation:
- Uses the
-roption to copy a directory and its contents recursively from the local system to the remote server.
scp root@192.168.1.34:/root/file.txt ./local/dir/scp -r root@192.168.1.34:/var/www/html/ /tmp/Explanation:
- Copies a file or directory from the remote server to the local machine. The
-roption is used for directories.
scp -l 500 file.zip root@192.168.1.20:/tmp/Explanation:
- The
-loption sets a bandwidth limit in kilobits per second (500 kbps in this case) to prevent network congestion.
-
Secure File Transfer:
SCP securely transfers files using an encrypted SSH connection. -
Data Integrity:
It encrypts files and authentication details, ensuring protection from unauthorized access. -
Multiple File Transfers:
SCP supports transferring multiple files simultaneously. -
Directory Transfer:
With-r, SCP can copy entire directories and their contents. -
Local and Remote Transfers:
SCP supports both local-to-remote and remote-to-local file transfers. -
Bandwidth Limiting:
The-loption lets you set bandwidth limits for transfers. -
Simplicity and Security:
SCP is easy to use and ensures secure file transfer via SSH.