How to Securely Transfer Files between Ubuntu Systems Using Croc

Croc is an open-source CLI-based tool that allows to securely transfer files between systems. During file transfer, a code is generated for the sender and the receiver systems to use for end-to-end encryption. Whether the sender and receiver are on the same network or the different networks, Croc can easily and quickly transfer files between them without the need for port forwarding. Croc can be installed and used on Linux, Windows, and MacOS, allowing you to share files between different operating systems.

In today’s tutorial, we will install Croc to securely transfer files between Ubuntu systems. To install Croc on Ubuntu, you should have root or sudo privileges.

Note: The procedure has been demonstrated on Ubuntu OS. You can use the same installation procedure for Debian OS.

Installing Croc on Ubuntu

For demonstration, we will use two Ubuntu 20.04 LTS machines. On both machines, we will install Croc. Follow the steps below to install Croc on the Ubuntu system.

Step 1: Download Croc

To download Croc, visit the Croc GitHub page and download Croc .deb package for Linux OS. You can download 32-bit or 64-bit depending on your OS architecture.

You can also use the command below to download the latest version of 64-bit Croc i.e. 9.4.2 (as of October 2021):

$ wget https://github.com/schollz/croc/releases/download/v9.4.2/croc_9.4.2_Linux-64bit.deb

Once downloaded, you will see the output as shown below.

Download Croc

Step 2: Installing Croc

After downloading, you can install Croc .deb package using the apt command.

Use the command below to install the Croc:

$ sudo apt install ./croc_9.4.2_Linux-64-bit.deb

If you have downloaded another version, make sure to replace it with the .deb file name used in the above command.

Also note that if the downloaded file is in another directory, make sure to first move inside that directory. Then you can run the installation command.

Install Croc

Step 3: Verifying Installation

To verify the installation of Croc, run the command below:

$ corc -v

If Croc has been installed successfully, the output will display the version of the Croc.

Check Croc version

Using Croc

After installing croc on both systems, we are ready to share files among them. Transferring a file with Croc is super easy. A sender just has to run a single command to send a file. This command generates a code. To receive that file, the receiver only has to type that code in their Terminal.

Transfer a Single File

To send a single file using Croc, move inside the directory where the file is located, and then use the command below:

$ croc send <filename>

For instance, to send a file named testfile.txt located inside the Home directory of the sender machine, run the command below:

$ croc send testfile.txt

After running the above command, you will see a code displayed in the output. Copy this code. In our example, the code displayed in the output is croc 6441-ballon-disney-domain.

Croc send file

Now on the other machine where you want to transfer the file, paste that code in the Terminal and hit Enter. After that, it will ask if you want to accept that file. Hit y to accept the file. Now the file will be transferred to the other machine.

Accept file sending request

By default, Croc asks if you want to overwrite an existing file. If you want Croc to overwrite an existing file without prompting, use the --yes --overwrite option as follows:

$ croc --yes --overwrite testfile.txt

Transfer Multiple Files

To transfer multiple files using Croc, move inside the directory which contains the files. Then use the command below:

$ croc send <filename1> <filename2> <filename3>

For instance, to send 3 files named testfile.txt, testfile2.txt, and testfile3.txt located inside the Home directory of the sender machine, run the command below:

$ croc send testfile.txt, testfile2.txt, and testfile3.txt

After running the above command, you will see a code displayed in the output. Copy this code.

Send Multiple files using Croc

Now on the other machine where you want to transfer these files, paste that code in the Terminal and hit Enter. After that, it will ask if you want to accept these files. Hit y to accept the files. Now all the files will be transferred to the other machine.

Accept files

To send multiple files, you can also use the wildcard character. For instance, to send all the files whose names end with .txt, you can use the wildcard character as follows:

$ croc send *.txt

Transfer a Directory

To transfer a directory using Croc, move inside the parent directory where the intended directory is located, then use the command below:

$ croc send <directoryname>

For instance, to send a directory named testdirectory located inside the Home directory of the sender machine, run the command below:

$ croc send testdirectory

After running the above command, you will see a code displayed in the output. Copy this code.

Transfer directory using Croc

Now on the other machine where you want to transfer the directory, paste the code in the Terminal and hit Enter. After that, it will ask if you want to accept the files. Hit y to accept the files. Now the directory with its contents will be transferred to the other machine.

Accept sent files

Transfer Using Custom code

While sending the file, you can also specify your custom code using the --code option.

$ croc send --code <code> <filename>

For instance, you want to use wonderful as a code when sending the file testfile.txt to another system. In this case, the command would be:

$ croc send --code wonderful testfile.txt

On the receiver side, you will have to use the above code to receive the file:

$ croc wonderful

Transfer Text

You can also send text to other machines using the --text option as follows:

$ croc send --text "this is URL"

Copy the code displayed on the sender machine and then paste it into the receiver machine's Terminal. After that, the specified text will be transferred to the other machine.

Uninstall Croc

If for any reason you want to remove Croc, use the command below to do so:

$ sudo apt remove croc

If it asks for confirmation, hit y and then Enter. After that, Croc will be removed from your machine.

In this post, we explained how to install and use Croc on Ubuntu OS. Now you can easily and securely transfer files between your Ubuntu machines. We also explained how to uninstall Croc in case you need to remove it from your system.