The scp command in linux is used to securely copy (scp – secure copy) files and folders from one linux server to another. The basic structure of the scp command is as follows:
scp source target
scp username@source_servername_or_ip:/path/to/file_or_directory location/to/copy/file_or_folder/to
When you run the above command from the target directory, you will be prompted to type the password for the username on the source server. The username should have at least read privileges to the file_or_folder you are trying to copy.
To copy to the current directory location, you can just specify a ‘.’ as below:
scp username@source_servername_or_ip:/path/to/file_or_directory .
To copy an entire directory, use the following command:
scp -r username@source_servername_or_ip:/path/to/directory .
Leave a comment