Securely Transfer Files and Folders Between Computers Using Croc

3
Croc, Securely Transfers Files and Folders Using Code Phrases

Croc is a free and open-source command line tool that allows any two computers to simply and securely transfer files and folders using code phrases.

There are lots of ways to transfer files between two or more computers. Today, we will discuss about yet another utility named Croc. This tutorial we’ll show you how to install Croc and how to use it to securely transfer files between computers.

Croc is a file transfer system that sends files securely using end-to-end encryption, via a file transfer relay. If you are curious about the name, it is inspired by the fable of the frog and the crocodile. The Croc key advantages are speed, security, and simplicity, all-in-one. Transferring data using Croc is faster, because it acts as a relay server between the systems. It creates a full-duplex real-time communication layer between the two computers, so the “uploading” and “downloading” tasks occur simultaneously between those computers.

Croc is a cross-platform tool. It is written in GO programming language and freely available under MIT license. You can install it on Linux, Mac, Windows, and Android, and securely transfer files between them. Croc does not only work in same LAN but on any two computers connected to the internet.

How to Install Croc Secure File Transfer App on Linux

Ubuntu / Debian

Download the latest release (.deb package) from the project website. Then you can install it by running apt install followed by the full path to the downloaded file:

apt install /home/linuxiac/Downloads/croc_9.1.3_Linux-64bit.deb
Reading package lists… Done
Building dependency tree       
Reading state information… Done
Note, selecting 'croc' instead of '/home/linuxiac/Downloads/croc_9.1.3_Linux-64bit.deb'
...
Unpacking croc (9.1.3) …
Setting up croc (9.1.3) …

Arch Linux

pacman -S croc

Others

The command shown bellow will install croc in /usr/local/bin/ location.

curl https://getcroc.schollz.com | bash

How to Securely Transfer Files Between Computers Using Croc

Using the croc command to send a file or folder from your computer to any other computer is as simple as it can get. Of course, croc needs to be installed on both computers, the one that’s sending the file(s) and the one receiving them.

To transfer a file/folder using croc, simply run:

croc send <file-or-folder-path>

Example:

croc send stuff.tar.gz
Did you mean to send 'stuff.tar.gz'? (y/n) y
Sending 'stuff.tar.gz' (640 B)
Code is: 1846-jump-mega-clean
On the other computer run

croc 1846-jump-mega-clean

Croc will generate random code phrase like above. Here, the code phrase is 1846-jump-mega-clean. The code phrase is used to establish password-authenticated key agreement (PAKE) which generates a secret key for the sender and recipient to use for end-to-end encryption. This ensures secure file transfers.

On the second computer (receiver), to receive the file or folder all you have to do is type croc <passphrase> (in this case it’s croc 1846-jump-mega-clean). Running this command will establish the connection with the sender, secure the channel and will ask you if you want to download whatever is being sent.

croc 1846-jump-mega-clean
Accept 'stuff.tar.gz' (640 B)? (y/n) y

Receiving (<-25.69.4.216:32816)
100% |████████████████████| (640/640 B, 5.479 kB/s)

Once you accept the transfer the download will begin and you will see the progress in your terminal emulator. Same thing goes for the sender. If you check the terminal on machine that’s sending the file, you will be able to see the transfer progress.

Sending (->46.215.23.41:38244)
 100% |████████████████████| (640/640 B, 418.001 kB/s)

Set Custom Croc’s Code Phrase

You can also securely transfer files or folders with a custom code of your choice using --code option.

croc send --code ps-forevermore stuff.tar.gz
Sending 'stuff.tar.gz' (640 B)
Code is: ps-forevermore
On the other computer run

croc ps-forevermore

The recipient can receive the file using the following command:

croc ps-forevermore
Accept 'stuff.tar.gz' (640 B)? (y/n) y

Receiving (<-25.69.4.216:38016)
100% |████████████████████| (640/640 B, 5.752 kB/s)

Send Text

You can also use croc to send text. This can be useful when you want securely to share a message or URL. To do that all you have to do is type:

croc send --text "You're the colour of my life"
Sending 'text' (28 B)
Code is: 1682-ozone-albert-celtic
On the other computer run

croc 1682-ozone-albert-celtic

The recipient can receive the text using the following command:

croc 1682-ozone-albert-celtic
Display text message (28 B)? (y/n) y

Receiving (<-13.80.4.226:42302)
You're the colour of my life

Use Croc with Your Own Relay Server to Securely Transfer Files

Now, baked into Croc’s configuration is the use of a public relay server that Croc’s creator has set up, but one can set up their own relay server, and configure croc to use that relay server at runtime. To do this requires a one-time setup on a third computer or in a docker container.

Run croc as a relay process on a server with a public address, for example 25.69.4.216:

croc relay
[info]    2021/05/12 19:36:22 starting croc relay version v9.1.3-e29b4c4
[info]    2021/05/12 19:36:22 starting TCP server on 9009
[info]    2021/05/12 19:36:22 starting TCP server on 9011
[info]    2021/05/12 19:36:22 starting TCP server on 9013
[info]    2021/05/12 19:36:22 starting TCP server on 9012
[info]    2021/05/12 19:36:22 starting TCP server on 9010

Then, we point croc away from the default public relay when sending a file:

croc --relay "25.69.4.216:9009" send some_file.extension
Sending 'stuff.tar.gz' (640 B)
Code is: 3036-finance-value-temple
On the other computer run

croc --relay 25.69.4.216:9009 3036-finance-value-temple

Then on the receiving end:

croc --relay 25.69.4.216:9009 3036-finance-value-temple
Accept 'stuff.tar.gz' (640 B)? (y/n) y

Receiving (<-46.215.23.41:41106)
 100% |████████████████████| (640/640 B, 3.918 kB/s)

Closing thoughts

In a nutshell, Croc does the following:

  • Securely transfer files, folders, and text between two computers using a relay
  • Provides end-to-end encryption using PAKE library
  • Transfers multiple files in one go
  • Resumes interrupted file copying
  • No central server port-forwarding needed
  • Requires Zero dependencies
  • Cross platform
  • Free and open source

Croc is definitely a tool that you need to check out if you are looking for a secure file transfer solution. There’s a lot more you can do with it and we encourage you to read the author’s blog post about the tool.

3 Comments

  1. What does this do that any of the many SSH-based tools available for Linux does not do already?

    • Thank you for the question, Jay. IMO, its big advantage is that it is cross-platform and enables easy cross-platform transfers (Linux, Windows, Mac).

  2. Interesting! As I get it, another advantage would be that the only Internet-exposed host would be the relay, and that server would contain no private data and no credentials (other the ones in temporary use). And it doesn’t require an open SSH port in the F/W I suppose?. Since it supports interrupted file transfers I suppose it somehow uses rsync?

Leave a Reply

Your email address will not be published.

Latest from Tutorials