Home File Transfer Transfer Files And Folders Between Computers With Croc

Transfer Files And Folders Between Computers With Croc

By sk
Published: Updated: 7.1K views

There are lots and lots of ways to transfer files between two or more computers. You could use server-based file sharing tools, peer-to-peer file sharing apps, USB sticks, external hard disk drives, SCP, NFS, FTP, HTTP, cloud storage platforms and many more. We have covered a few file sharing tools already. Today, we will discuss about yet another file transfer utility named Croc.

What is Croc?

Croc is a command line file sharing utility that allows you to easily, quickly and securely transfer files and folders between Computers.

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 provides end-to-end encryption using Password Authenticated Key Exchange (PAKE) library. For those wondering, the PAKE library allows two people to generate a strong secret key by using a weak key that is known to both beforehand. This secret key is then used for further encryption. Since the key is known by only the sender and receiver, no one else can learn the secret key even if they know the original password.

Croc can be able to transfer multiple files at once between computers. If the data transfer is interrupted for any reason, it can resume file copying from where it was left last time.

Since Croc uses relay, you don't need either a central server or port forwarding. It is a cross-platform application, so you can transfer the data between Linux, Mac and Windows platforms.

In a nutshell, Croc does the following:

  • transfers data 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,
  • ipv6-first with ipv4 fallback,
  • requires Zero dependencies,
  • cross platform,
  • free and open source.

Croc is written in GO programming language and freely available under MIT license.

Install Croc on Linux

Croc can be installed on any Linux and Unix distributions that supports Bash using the following command:

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

This command will install Croc in /usr/local/bin/ location.

If you don't want to inject something directly into your SHELL, you can download the pre-compiled binaries from the releases page and install them using your distribution's package manager.

For instance, I installed Croc deb file on my Ubuntu system using the following commands:

$ sudo apt install gdebi
$ sudo gdebi croc_8.3.2_Linux-64bit.deb

Croc is available in the [Community], so you can install it on Arch Linux and its variants using pacman like below:

$ sudo pacman -S croc

On NixOS, run:

$ nix-env -i croc

Croc is also available as snap.

$ snap install croc

You can also build Croc from source if you have installed Go on your Linux system.

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

Transfer Files And Folders Between Computers With Croc

Make sure you have installed Croc on all systems.

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

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

Example:

$ croc send file.txt

Croc will generate random code phrase like below.

Sending 'file.txt' (116 B)
Code is: slow-tomato-almond
On the other computer run

croc slow-tomato-almond

Here, the code phrase is slow-tomato-almond. 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.

To receive the above file on the other computer, the recipient should enter the last line in the above output:

$ croc slow-tomato-almond

Press "y" and hit enter to receive the file.

Accept 'file.txt' (116 B)? (y/n) y

Receiving (<-192.168.225.37:9009)
file.txt 100% |████████████████████| (116/116 B, 32.966 kB/s) [0s:0s] ✔️

Sample output:

Transfer Files And Folders Between Computers With Croc
Transfer Files And Folders Between Computers With Croc

Set custom code phrase

Like I already mentioned, Croc will generate a random code every time you send a file or folder. You can also send files/folders with a custom code of your choice using --code option.

$ croc send --code download-this file.txt

Here, "download-this" is the code phrase.

Sample output:

Sending 'file.txt' (116 B)
Code is: download-this
On the other computer run

croc download-this

The recipient can receive the file using the following command:

$ croc download-this
Send files and folders with a custom code using croc
Send files and folders with a custom code using croc

Send text

Just like files and folders, we can share the text as well. This can be useful when you want to share a message or URL.

To send text using Croc, run:

$ croc send --text "Welcome to OSTechNix"

Sample output:

Sending 'text' (20 B)
Code is: natural-roof-clock
On the other computer run

croc natural-roof-clock

Sending (->[fe80::a00:27ff:fe10:7cc1%wlp9s0]:39916)

The recipient will get text using the following command:

$ croc natural-roof-clock
Accept 'text' (20 B)? (y/n) y

Receiving (<-[fe80::d710:cf4:bb49:8b20%enp0s8]:9009)
Welcome to OSTechNix
Send text using croc
Send text using croc

Use pipes

You can pipe the file's output to croc like below.

$ cat file.txt | croc send

Sample output:

Sending 'stdin' (116 B)
Code is: dexter-cowboy-soprano
On the other computer run

croc dexter-cowboy-soprano

Croc will automatically use the stdin data and send and assign a filename like "croc-stdin-728899651".

On the receiving end, the user can receive the file using any one of the following commands:

$ croc dexter-cowboy-soprano

Or, use:

$ croc --yes dexter-cowboy-soprano > out

Here, --yes will not ask any confirmation and automatically agree to all prompts.

Set output folder

By default, Croc will download the data in the current working directory. You can make it to use different download location using --out flag.

$ croc send file.txt

Sample output:

Sending 'file.txt' (116 B)
Code is: program-public-mystery
On the other computer run

croc program-public-mystery

On the receiving end, run:

$ croc --out ~/Downloads

Enter the code phrase when prompted.

Getting help

For help, run:

$ 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-passphrase file.txt

VERSION:
   v8.3.2-7d155ad

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)
   --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]
   --help, -h      show help (default: false)
   --version, -v   print the version (default: false)

Resources:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

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

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More