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@ /home/web/

Copying all files and folders from the directory /var/www/user/data/www/ on server into the local folder /home/web/

  • Recursive copying of the directory between remote servers:
 scp -r root@ root@

Copying all files and folders from the directory /var/www/user/data/www/ on server into the folder /home/web/ on server

  • Copying one file from a remote server:
 scp root@ /home/web/

Copies the file img.jpg from the directory /var/www/user/data/www/ on the server into the local folder /home/web/

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.

Updated Sept. 9, 2022