The SCP ( Secure Copy Protocol ) is a network protocol, based on the BSD RCP protocol, which supports file transfers between hosts on a network. SCP uses Secure Shell (SSH) for data transfer and uses the same mechanisms for authentication.
Using SCP you can copy file/directory :
While transferring data using SCP, files and password is encrypted, so that anyone snooping on the traffic doesn’t get anything sensitive.
Things to keep in mind before the start -
The syntax for the scp command is:
scp [options] username@source_host:directory/filename /where/to/put
In the below examples I Recursively copying entire directories -
From remote to local -
scp -r username@ipaddress:/directory/to/send /local/where/to/put
From local to remote -
scp -r /local/directory/to/send username@ipaddress:/where/to/put
Copying between two remote hosts -
scp -r username@ipaddress1:/file/to/send username@ipaddress2:/where/to/put
You can use scp with the following options according to your requirements.
scp –P port : Generally 22 as a default port of scp. You can also specify a specific port. scp –p : An estimated time and the connection speed will appear on the screen. scp –q : Disable progress meter and warning. scp –r : Recursively copy entire directories. scp –v : Print debug information into the screen. It can help you debugging connection, authentication and configuration problems. scp -c : By default SCP using “AES-128” to encrypt files. If you want to change to another cipher to encrypt it, you can use “-c”.
I hope that you now have understood how to make the best use of scp command to securely transfer files between the systems.
If you have any suggestions on your mind, please let me know in the mail