In this guide we will be discussing the installation and use of Croc. A tool that is very useful in securely transferring files between computers. It does many things, among them are:

  1. Provides an end encryption using password Authenticated Key (PAKE)
  2. Ability to transfer files at the same time
  3. It is fast as it acts as a relay server between computers
  4. No port forwarding required from a central server
  5. It is an open source tool.
  6. One can resume transfers after an interrupt.
  7. Requires no dependencies
  8. Ipv6-first with ipv4 fallback

This tool is written in GO language, free and open source under MIT license. With these features, Croc definitely becomes a tool of interest to have for file sharing.

How to install Croc on Linux

Croc can be installed and run on any linux distribution. To make your installtion, run the following command:

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

Sample output:

$ curl https://getcroc.schollz.com | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25248  100 25248    0     0  24899      0  0:00:01  0:00:01 --:--:-- 24899
=================================================
              ____
             / ___|_ __ ___   ___
            | |   | '__/ _ \ / __|
            | |___| | | (_) | (__
             \____|_|  \___/ \___|

       ___           _        _ _
      |_ _|_ __  ___| |_ __ _| | | ___ _ __
       | || '_ \/ __| __/ _` | | |/ _ \ '__|
       | || | | \__ \ || (_| | | |  __/ |
      |___|_| |_|___/\__\__,_|_|_|\___|_| 
==================================================
== Install prefix set to /usr/local/bin
== Created temp dir at /tmp/croc.g1e6x2
== Architecture detected as x86_64
== OS detected as Linux
== Downloaded croc archive into /tmp/croc.g1e6x2
== Downloaded croc checksums file into /tmp/croc.g1e6x2
== Checksum of /tmp/croc.g1e6x2/croc_9.2.0_Linux-64bit.tar.gz verified
== Extracted croc_9.2.0_Linux-64bit.tar.gz to /tmp/croc.g1e6x2/
== Install prefix already exists. No need to create it.
== Installed croc to /usr/local/bin/
== Installed autocompletions for bash
== Installation complete

Running this command installs croc in this location /usr/local/bin/

But if you do not like this installation links directly with the shell, you can download these binaries from the release page and install them using the system’s package manager

Download Croc from the releases page

For Debian users/ Ubuntu you can install Croc with these commands:

sudo apt install gdebi
sudo gdebi croc_9.2.0_Linux-64bit.deb

To install Croc using snap, run:

snap install croc

Since Croc uses Go language, once you have Go installed on your system, you can easily install Croc with this command:

GO111MODULE=on go get -v github.com/schollz/croc/v8

Croc can be installed on Arch linux using pacman with these commands;

pacman -S croc

Transfer Files Between Computers With Croc

Having installed Croc on both computers, you can proceed to file transfer using;

$ croc send <file-or-folder-path>

Example

$ croc send /root/droidcam-64bit.tar.bz2

Output:

On the receiving computer, this phrase 2711-quebec-rocket-button establishes a password authenticated key (PAKE) which is used to generate the end-to-end encryption for both computers.

On the receiving computer, enter the phrase given by the sending computer

Example:

$ croc 2711-quebec-rocket-button

Running this command establishes an agreement between the computers and initiates the transfer. You are required to hit “y” receive the file

This is the output on both computers after a successful file transfer

Setting a custom phrase code

Since Croc generated a code to authenticate and create an agreement between the computers, you can choose a custom code instead of randomizing the codes. customizing a code is achieved with the –code flag

$ croc send --code use-this-code IMG.png

In this case use-this-code is the phrase to be used when receiving files as demonstrated below:

Sending text Using Croc

Similarly to sending files, one can easily send texts using Croc. This can be useful in instances where you want to share a URL to the recepient.

This is achieved by using;

$ croc send --text "Thanks for Visiting Techviewleo"

This is the output on both sending and receiving computer

Using Pipe In Croc

In croc, you can pipe an output with this command:

cat config.yaml | croc send

To receive the file, use;

croc 4283-tibet-alarm-table

or

croc --yes 4283-tibet-alarm-table > out

Using yes does not ask you any confirmation as you have agreed already.

The sample output on both screens is;

Using pipe uses stdin to assign the filename sent, from the below illustrations the received files are named with the stdn string

Setting The Folder for Croc output

Normally, Croc downloads your received file in the current working directory. To set a specific folder to download your files in you add the flag –out

croc --out ~/Downloads

This command specifies the donload folder as /Downloads.

Get Usage help

If you get stuck using Croc, run this command for help

$ croc --help
NAME:
   croc - easily and securely transfer stuff from one computer to another

USAGE:
   Send a file:
      croc send file.txt

   Send a file with a custom code:
      croc send --code secret-code file.txt

   Receive a file using code:
      croc secret-code

VERSION:
   v9.2.0-d442755

COMMANDS:
   send     send a file (see options with croc send -h)
   relay    start your own relay (optional)
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --remember      save these settings to reuse next time (default: false)
   --debug         toggle debug mode (default: false)
   --yes           automatically agree to all prompts (default: false)
   --stdout        redirect file to stdout (default: false)
   --no-compress   disable compression (default: false)
   --ask           make sure sender and recipient are prompted (default: false)
   --local         force to use only local connections (default: false)
   --ignore-stdin  ignore piped stdin (default: false)
   --overwrite     do not prompt to overwrite (default: false)
   --curve value   choose an encryption curve (p521, p256, p384, siec) (default: "siec")
   --ip value      set sender ip if known e.g. 10.0.0.1:9009, [::1]:9009
   --relay value   address of the relay (default: "142.93.177.120:9009") [$CROC_RELAY]
   --relay6 value  ipv6 address of the relay (default: "[2604:a880:800:c1::14c:1]:9009") [$CROC_RELAY6]
   --out value     specify an output folder to receive the file (default: ".")
   --pass value    password for the relay (default: "pass123") [$CROC_PASS]
   --socks5 value  add a socks5 proxy [$SOCKS5_PROXY]
   --help, -h      show help (default: false)
   --version, -v   print the version (default: false)

Conclusion

In the above guide we have been able to use Croc to share files between two computers. This tool is very helpful in situations where you do not have portable media devices and might be handy for Linux users.

Check some of our other articles on this site

LPIC 101 – Locating and Finding Files on Linux Filesystems

Install and Configure Samba File Sharing on Rocky Linux 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here