DCP – Transfer Files Between Linux Hosts Using Peer-to-Peer Network

People often need to copy or share files over the network. Many of us are used to using tools such as rsync or scp to transfer files between machines. In this tutorial, we are going to review another tool that can help you copy files between hosts in a network – Dat Copy (dcp).

Dcp does not require SSH to be used or configured in order to copy your files. Furthermore it does not require any configuration to securely copy your files.

Dcp Use Cases

Dcp can be used in multiple scenarios. For example, you can easily send files to multiple colleagues by simply providing them with the generated key. You can also sync data between two machines without the need of setting SSH keys. Copy files to remote machine or share files between Linux, MacOS, Windows.

How Dcp Works

Dcp creates a dat archive for the list of files you have specified to be copied over. Then, using the generated public key it allows you to download the files from another host. The copied data is encrypted using the public key for the dat archive.

How to Install Dcp in Linux Systems

Installation of dcp can be completed with npm package manager. However if you don’t wish to use npm, you can download the latest release of the dcp package from the release page.

To install the package with npm, you must have NPM installed on your Linux system and then use the following command to install it.

# npm i -g dat-cp

If you prefer to use the zip archives, you can download them with wget command.

# wget https://github.com/tom-james-watson/dat-cp/releases/download/0.7.4/dcp-0.7.4-linux-x64.zip

Then move the dcp and node-64.node binaries to a path by your choice, preferably a path that is included in your PATH variable. For example /usr/local/bin/:

# mv dcp-0.7.4-linux-x64/dcp dcp-0.7.4-linux-x64/node-64.node /usr/local/bin

How to Use Dcp in Linux Systems

Usage of dcp is simple and as mentioned earlier does not require any extra configuration. Simply choose the files that you wish to copy and run:

Send file from source host:

# dcp file

Run the command below on the target host.

# dcp <generated public key>

It may look a little strange at first, but it is actually very easy. For the purpose of this tutorial, I have two hosts – temcint_1 and tecmint_2. I will send file called video.mp4 from tecmint_1 to tecmint_2.

Sending the file from tecmint_1:

# dcp video.mp4

In the end of the output, you will see a blue line, which will be dcp <generated public key>:

Send File to Remote Host

Send File to Remote Host

You can then use the following command to obtain the file from another host. In the below example, I will download the file from tecmint_2:

# dcp c3233d5f3cca81be7cd080712013dd77bd7ebfd4bcffcQ12121cbeacf9c7de89b
Download File from Remote Host

Download File from Remote Host

That’s it, the file has been downloaded.

Dcp has some extra options you can run it with:

  • -r, --recursive – recursively copy directories.
  • -n, --dry-run – show what files would have been copied.
  • --skip-prompt – automatically download without a prompt.
  • -v, --verbose – verbose mode – prints extra debugging messages.

Dcp is very simply and easy to use tool, that helps you copy or share files between hosts. If you like the project, you can further review the dcp git page.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Marin Todorov

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

3 Responses

  1. David says:

    Great question, Jordi. I was curious about exactly the same configuration-related characteristics.

  2. Jordi says:

    Does dcp uses any particular TCP port it relies on?

    If it does not require ssh. What protocol does it rely on?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.