×


Using SCP Command in DigitalOcean Server - All about it ?

SCP (Secure Copy) is a command line tool for Linux systems for securely transferring files from a remote server to the local system or vice versa. SCP uses SSH protocol for transferring files between two systems which is more secure than FTP.
With SCP command in DigitalOcean, files can be easily transferred.
Here at Ibmi Media, we shall look into how to use scp command to transfer files in your DigitalOcean Droplet server.

How to use SCP in your DigitalOcean droplet ?

Secure Copy Protocol or SCP runs on CLI via the scp command with the help of SSH for data transfer. The SCP command also has several additional options that specify hosts, authentication parameters as well as ports.
By default, the SCP protocol runs on port 22.
It takes the below command query:
$ scp [OPTIONS] [SOURCE] [DESTINATION]
Also, with the scp command, it is possible to move several files on the DigitalOcean server. However, both the droplets have to be in the same region for the process to succeed.
The follow steps should be taken to move several files using the scp command:
1. To begin with, we have to enable the private network for the droplets.
2. Then, we have to enable eth1 for both the droplets.
3. Next, run the following command to copy files from the source server to the destinations server:
$ scp -r /srv/users/serverpilot/apps/XXX/public/resources root@10.12.13.10:/srv/users/serverpilot/apps/XXX/public
Here, 10.12.13.10 is the private IP address of the destination server. We can identify this via the DigitalOcean admin area under settings, Alternatively, we can run ifconfig via SSH as well.
Also, we can transfer files over SSH with the SCP DigitalOcean command:
$ scp -r /folder1/folder2//myfiles root@0.0.0.0:/path/on/remote/droplet
Make sure you replace 0.0.0.0 with the droplet's IP address. We also have to update the paths as per our requirements.
If we want to transfer files to a different port, we have to use the -P flag as seen below:
$ scp -P 2222 -r /folder1/folder2/myfiles root@0.0.0.0:/path/on/remote/droplet

[Need help in fixing Ubuntu Linux server issues ? We can help you. ]


Conclusion

This article covers how to use SCP command in DigitalOcean to transfer files. In fact, The secure copy protocol also follows regular command-line and SSH functionality, helping to create a seamless command set for managing files between Linux machines.


SCP Command Options includes:

  • -1 Use protocol 1.
  • -2 Use protocol 2.
  • -4 Only use Ipv4 addresses.
  • -6 Only use IPv6 addresses.
  • -B Run in batch mode, disabling all queries for user input.
  • -b buffer_size Specify the buffer size used for data transfer. If not specified, uses the default - 32768 bytes.
  • -C Enable compression.
  • -c cipher Select the cipher for data encryption. If not specified, SCP uses the default - ‘AnyStdCipher’.
  • -D debug_level Set the debug level (1, 2, 3, or 99).
  • -d Copy the file, only if the destination directory already exists.
  • -F file Specify an alternative configuration file for SSH.
  • -h Show a list of command options.
  • -i file Specify the file from which to read the identity for public key authentication.
  • -l limit Limit the bandwidth (specify the limit in Kbit/s).
  • -o ssh_option Set options to SSH in ssh_config format.
  • -P port Specify the port to which to connect. If not specified, SCP uses port 22.
  • -q Run SCP in quiet mode.
  • -Q Disable displaying any file transfer statistics.
  • -r Copy recursively.
  • -S program Use a specified program for encryption connection.
  • -u Delete the source file once the copy is complete.
  • -v Enable verbose mode, which sets the debug level to 2.