Psychz - Girish
Votes: 0Posted On: Jul 11, 2017 04:27:26
SCP stands for Secure Copy. It a very useful command used to copy files from remote to local host and vice versa over an SSH connection. When we initiate the copying of files from remote to a local system through "scp" command, the OpenSSH server daemon regulates the secure copy of files after authentication.
Prerequisites
1. "scp" should be installed on your system. If not, install it by running the following command.
1.sudo apt install openssh-client (For Debian/Ubuntu)
2. sudo yum install openssh-client (For RPM packages)
2. There should be an SSH connection between the remote and local host.
Copying Files using Scp from remote to local machine
The syntax of the scp command while copying files from remote to local machine is as follows.
scp username@remote_host:path_of_remote_file place_to_copy_on_local_machine
# If you want to copy to the current local directory you are accessing, just put a "." in place of the destination path.
scp username@remote_host:path_of_remote_file .
Copying Folders using Scp from remote to local machine
To copy folders use the "-r" option. "-r" stands for recursive as it copies the folder and its subfolder as well.
scp -r username@remote_host:path_of_remote_folder place_to_copy_on_local_machine
Some useful options to use with scp command
1. The "-P" option is used to specify port to the remote host.
2. The "-v" option is used to turn on the verbose mode. The verbose mode ensures the printing of all the debugging messages on the screen.
3. The "-q" option is the quiet mode. It disables all the messages from the SSH client.
4. The "-l" option limits the bandwidth usage.
It is recommended to go through the manual of scp command to get a hold on all the options. You can use the command
man scp