croc Is A Tool For Resumable, Encrypted File And Folder Transfers Between Computers (Command Line)

croc encrypted file transfer command line

croc is a free and open source command line tool for secure file transfers between computers. It uses relay-assisted peer-to-peer transactions and end-to-end encryption via password-authenticated key exchange. The program is written in Go and is available for Microsoft Windows, macOS, Linux and *BSD.

The idea behind croc is being able to transfer files and folders between cross-platform computers securely, fast and easy. With support for resumable, peer-to-peer transfers. As a bonus feature, croc is also able to securely transfer a short text or URL directly.

The data transfer is done using a relay, either using raw TCP sockets or websockets. When the sender and the receiver are on the same LAN, croc uses a local relay, otherwise a public relay is used. Thanks to this, croc can send files between computers in the same LAN, or over the Internet, without having port-forwarding enabled.

The data going through the relay is encrypted using a PAKE-generated session key. For this, croc uses code phrases, a combination of three random words. By default, a code phrase can only be used once between two parties, so an attacker would have a chance of less than 1 in 4 billion to guess the code phrase correctly to steal the data. 

croc features:

  • allows any two computers to transfer data (using a relay)
  • provides end-to-end encryption (using PAKE)
  • enables easy cross-platform file and folder transfers (Windows, Linux, Mac and *BSD)
  • allows multiple file transfers
  • allows resuming transfers that are interrupted
  • local server or port-forwarding not needed
  • IPv6-first with IPv4 fallback
  • can use a proxy, like Tor

The developer mentions that croc is the only command line file transfer tool that has all the features mentioned above.

croc also supports starting your own relay (croc relay; you can easily self-host a relay using Docker), setting a custom (non-croc generated) code phrase (croc send --code), automatic agreeing to all prompts (--yes), and there are various other options like forcing the use of local connections (--local), specify the relay address (--relay / --relay6), use a Socks 5 proxy (--socks5), etc. You can save some of these options for future uses (the custom relay, ports and code phrase) using the --remember option .See the croc --help, as well as croc send --help for details. 

You might also like: qrcp: Transfer Files Between Desktop And Mobile Devices Over Wi-Fi By Scanning A QR Code

Worried that this is a command line tool, and that it's hard to use by an inexperienced user on Microsoft Windows? It's not. A Windows user can simply download the Windows binary, extract it, then double-click the croc.exe executable, and a console window will pop up, asking the user to enter the receive code:

croc Windows

Another tool close in functionality to croc is Magic Wormhole. This is a Python3 command line tool to send files and folders between computers. The differences are that Magic Wormhole is written in Python, so it requires installing its dependencies (croc is written in Go, so you can use the binary without having to install any dependencies), and Magic Wormhole doesn't support multiple file transfers, file resuming, IPv6,  local transfer without public relay, sending folders without zipping, and it's not that easy installing it on Windows.

croc usage

Using croc to send a file or folder is as simple as:

croc send file-or-folder

For example:

$ croc croc_8.6.8_Linux-64bit.deb

Did you mean to send 'croc_8.6.8_Linux-64bit.deb'? (y/n) y
Sending 'croc_8.6.8_Linux-64bit.deb' (2.1 MB)
Code is: life-brother-chicken

On the other computer run

croc life-brother-chicken

As you can see from the command output, when sending a file, croc show a code in the form of an easy to remember phrase. The instructions for receiving the file are also shown here - so to get the file, the receiver needs to run the croc command followed by the code of the file / folder:

croc code-phrase


$ croc life-brother-chicken

Accept 'croc_8.6.8_Linux-64bit.deb' (2.1 MB)? (y/n) y

Receiving (<-
croc_8.6.8_Linux-64bit.deb 100% || (2.1/2.1 MB, 2.153 MB/s)

Once the receiver runs the croc command to get the file, the sender will see a message saying something like this:

Sending (->

After the file transfer is complete, croc exists, so the file can no longer be downloaded again. If you want to cancel the file transfer before it completes (or before it even begins), press Ctrl + c.

You can also use croc to securely send a short text or URL between computers, using:

croc send --text "Some text"

For even more, like using pipes, etc. see the croc usage from its GitHub repository.

Related: ffsend: Secure File Share From The Command Line (Firefox Send Client)

Download croc

There are croc binaries available for Microsoft Windows, macOS, FreeBSD and Linux.

On Linux you'll only find DEB binaries (for Debian / Ubuntu / Linux Mint / Pop!_OS / etc.), as well as generic binaries that you can install on any Linux distribution, by copying it somewhere in your PATH (e.g. /usr/local/bin).

See the croc official installation instructions for a complete list of ways you can install this command line tool (a generic script to install it on any Linux distribution, the tool is available in the Arch Linux repositories, install it using Homebrew, Chocolatey, etc.).

You might also like: How To Encrypt Cloud Storage Files With Rclone