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.
Conclusion

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.

If this article helped, with someone on your team.

TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
☕ Buy Me a Coffee
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.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

3 Comments

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Something went wrong. Please try again.
Check your email for a magic link to get started.