SCP (secure copy) is a utility and protocol for copying files between computers, using encrypted SSH as the transport.
Command syntax for copying files between servers:
scp option user1@server1:file/folder (WHERE and WHERE) user2@server2:folder (WHERE)
The utility options are more about the SSH protocol and configure its overall behavior.
Next comes the address of the first and second file. Each of these can be located either on the local or remote.
A list of keys that may be useful:
- -1 - to use the SSH1 protocol;
- -2 - to use SSH2 protocol;
- -B - batch mode to transfer multiple files;
- -C - enable compression;
- -l - set speed limit in kbps;
- -o - set the desired SSH option;
- -p - save modification time;
- -r - recursive copying of directories;
- -v - more detailed mode.
As a user, you have to use any user that you have on the server. You can also use the server domain instead of IP. It is necessary that the selected user has write permissions to the specified folder.
Examples of working with SCP utility
- Recursive copying of a directory and all folders/files in it:
scp -r root@1.111.1.111:/var/www/user/data/www/site.ru/upload /home/web/test.site.ru/public_html/
Copying all files and folders from the directory /var/www/user/data/www/site.ru/upload
on server 1.111.1.111
into the local folder /home/web/test.site.ru/public_html/
.
- Recursive copying of the directory between remote servers:
scp -r root@1.111.1.111:/var/www/user/data/www/site.ru/upload root@2.222.2.222:/home/web/test.site.ru/public_html/
Copying all files and folders from the directory /var/www/user/data/www/site.ru/upload
on server 1.111.1.111
into the folder /home/web/test.site.ru/public_html/
on server 2.222.2.222
.
- Copying one file from a remote server:
scp root@1.111.1.111:/var/www/user/data/www/site.ru/upload/img.jpg /home/web/test.site.ru/public_html/upload/
Copies the file img.jpg from the directory /var/www/user/data/www/site.ru/upload
on the server 1.111.1.111
into the local folder /home/web/test.site.ru/public_html/upload/
.
Note that the folder you are going to copy must end with a slash, otherwise the folder you copy will be written instead of the one you want to copy to.
If you have difficulty setting up or have additional questions, you can always contact our support team via ticket system.