Transferring files between a computer and mobile device can be achieved through many ways. In this guide, we I will demonstrate how to share files over WiFi by scanning a QR code with your phone.

Qrcp formerly known as Qr-transfer is the easiest method to link and transfer files between your computer and mobile device without leaving the terminal. A simple command is used to send and receive files.

When sending files, Qrcp binds a web server address to your network interface card and creates a random port for it. A QR code is then displayed on your terminal or web browser depending with your configuration. This also works the same when receiving files, it receives an upload page and initiates the transfer.

Installing QRCP on Linux Systems

Installation of QRCP can be done in many ways as listed below. Choose one that works best for your system.

Option 1. Install QRCP with Golang.

Since QRCP uses Go programming language, its necessary we install it before we can proceed.

Download and install Go from their official page.

After installation is complete, proceed and install QRCP

go get github.com/claudiodangelis/qrcp

Option 2. Install QRCP using Package Managers

Installing on Arch / Manjaro Linux

QRCP is available in AUR repositories which can be accessed in the following links

Yet another Yaourt abbreviated as Yay. Is another way to get QRCP installed. Yaourt provides an interface for pacman and also has almost no dependencies. Your can install QRCP with:

yay -S qrcp-bin

Alternatively, you can use this:

yay -S qrcpyay -S qrcp

Installing on Debian/Ubuntu Linux

For debian users, you can download and install QRCP with:

sudo apt update
curl -s  https://api.github.com/repos/claudiodangelis/qrcp/releases/latest |grep browser_download_url |  cut -d '"' -f 4 | grep linux_x86_64.deb | wget -i -
sudo apt install ./qrcp_*_linux_x86_64.deb

Confirm installation:

$ qrcp version
qrcp 0.8.4 [date: 2021-04-24T17:22:16Z]

Installing on RHEL/CentOS

For RPM-based systems such as Rocky Linux, RHEL, CentOS .rpm files can be downloaded with the command

curl -s  https://api.github.com/repos/claudiodangelis/qrcp/releases/latest |grep browser_download_url |  cut -d '"' -f 4 | grep linux_x86_64 | wget -i -
sudo yum localinstall ./qrcp_*_linux_x86_64.rpm

Accept installation using the y key:

Last metadata expiration check: 2:48:46 ago on Wed 23 Jun 2021 05:28:44 PM CEST.
Dependencies resolved.
==================================================================================================================================================================
 Package                            Architecture                         Version                                 Repository                                  Size
==================================================================================================================================================================
Installing:
 qrcp                               x86_64                               0.8.4-1                                 @commandline                               3.7 M

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 3.7 M
Installed size: 9.3 M
Is this ok [y/N]: y

Option 3. Install QRCP from binaries.

Download QRCP from the release page with this command

curl -s  https://api.github.com/repos/claudiodangelis/qrcp/releases/latest |grep browser_download_url |  cut -d '"' -f 4 | grep linux_x86_64.tar.gz | wget -i -

Then extract the downloaded file

tar xvf qrcp_*_linux_x86_64.tar.gz

Move the file to /usr/local/bin with

sudo mv qrcp /usr/local/bin

Set executable permissions of the moved file by issuing this command

sudo chmod +x /usr/local/bin/qrcp

The last step is not much neccessary because moving the file to the path makes it executable.

You can confirm your QRCP version by:

$ qrcp version
qrcp 0.8.4 [date: 2021-04-24T17:22:16Z]

By the time of this documentation, this was the latest QRCP version. Ensure you install the latest version of QRCP before you can proceed.

In case you cannot find your QRCP version, run this command to declare the path:

export PATH="/usr/local/bin:$PATH"

Transfer Files Using QRCP

With QRCP installed, file transfer is easy. For this guide, I will use Rocky Linux 8 and an Android moblile phone. Before this, make sure you have a QR reader installed on your phone.

Sending files to your Mobile phone with QRCP

First, let us begin by sending files from the linux system to a mobile phone. First ensure there is a connection running between your devices like WiFi. Connect both devices before you can transfer the files.

When QRCP is launched for the first time, you might be required to choose a connection you want to use for file transfer such as wlp9s0.

Begin sending files with:

$ qrcp <file-to-send>

In this instance, I am sending a file qrcp_0.7.0_linux_x86_64.tar.gz located in the root folder.

After this, a QR will appear on your terminal.

Scan the above code with your phone and open the URL in your favorite browser.

When you open in a browser, you are prompted to accept your download as below.

If you accept this download, the file with be downloaded in the default download folder of your phone.

You can also share multiple files using this command.

qrcp fileA fileB

This is demonstrated as below. In this case, I send two files as shown below /etc/hosts and /etc/hostname

These files with be downloaded as a zipped file in your phone.

In instances where you are required to send a whole folder, do it with the command:

qrcp ~/Documents/qrcp ~/Documents/

When sharing large files, you are required to zip them and send with the zip flag as below

qrcp --zip musicmix.mp4

Receiving files on your computer from your phone with QRCP

Now let us receive files on our computer from a mobile device. This is easy as well, it is achieved by running this command

qrcp receive

This also displays a QR code on your terminal.

Scan the code with your phone and open it in a browser. The following interface will be displayed on your phone’s browser.

Here, you are required to select the file you want to send to your computer. After selecting the desired file, click transfer and the file will be transferred to your computer.

On your computer terminal, you will see this

From the above image, we see the file has been received and also the directory to find the file is shown. Navigating to the directory, we see the received file as below.

Normally, the file is received in the current working directory, but in case you want your file to go to a specific directory use this command:

qrcp receive --output=Downloads

With this command running, your received files will appear in the /Downloads directory.

QRCP Configuration

By default, QRCP works without prior configurations. However you can configure QRCP to use specific network interface, use specific port, specific directory to save received files among many more other settings.

Normally the default configuration file is stored in Home/.qrcp.json. QRCP reads and uses the file with the defined parameters.

To configure the parameters,we use:

qrcp config

Choose the network interface you want to use

Incase you cannot see your desired network interface, issue this commnad:

qrcp --list-all-interfaces config

This lists all the network interfaces available on your computer.

Next, enter a Fully Qualified Dormain Name (FQDN)

✔ Choose fully-qualified domain name: qrcp.techviewleo.com

Then, choose a port. For me I chose a random port

✔ Choose port, 0 means random port: 0

Enter the folder to save received the files

✔ Choose path, empty means random: /root/Downloads

You can choose if you want to keep the server alive after the transfer.

? Should the server keep alive after transferring?: 
  ▸ No
    Yes

Select the appropriate option incase you want to securely transfer your files.

? Should files be securely transferred with HTTPS?: 
  ▸ No
    Yes

Choosing YES, you will be required to enter TLS certificate path and TLS certificate key to secure your files.

Having all this set, the QRCP configuration is now updated to new values as below.

Configuration updated:
{
  "fqdn": "qrcp.techviewleo.com",
  "interface": "enp0s3",
  "port": 0,
  "keepAlive": false,
  "path": "/root//Downloads",
  "secure": false,
  "tls-key": "",
  "tls-cert": ""
}

Aside from the assigned parameters, one can assign custom parameters using these commands.

Secure Transfers using Mkcert.

Mkcert is a simple way used to make locally-trusted certificates used by QRCP to transfer files. Generating these certificates is quite easy.

First, create a directory called certs, which will be used for the certificate files using this command

mkdir cert

Then we navigate to the directory created and install mkcert in it with:

mkcert --install

If the installation works successfully you will be able to see this,

Created a new local CA at "/home/me/.local/share/mkcert"
Sudo password:
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox and/or Chrome/Chromium trust store (requires browser restart)!

Now generate certificates with:

mkcert 192.168.1.19

You should see this output

Using the local CA at "/home/me/.local/share/mkcert"

Created a new certificate valid for the following names 
 - "192.168.1.19"

The certificate is at "./192.168.1.19.pem" and the key at "./192.168.1.19-key.pem" 

With this, you can now securely transfer your files. To check the location of the root certificate’s parent directory, run:

mkcert --CAROOT

Now you can transfer your files securely using:

qrcp --tls-cert ~/certs/192.168.1.19.pem --tls-key ~/certs/192.168.1.19-key.pem IMAGE.png

Customize Port

To set a custom port use this command

qrcp --port 8080 file.txt

In the above code, the assigned port is 8080

Use specified Network Interface for file sharing

With this command, you can set which interface to be used by QRCP for file transfer.

qrcp -i enp0s3 file.txt

In the above code, the network interface set is LAN

Instead of using IP address use FQDN

Normally, QRCP uses the system’s IP address for file sharing. But if you want to use FQDN, you will be required to issue this command

qrcp --fqdn qrcp.techviewleo.com -i enp0s3 -p 8080 file.txt

In this instance, I used qrcp.techviewleo.com as my FQDN. You need to substitute it with your own FQDN

Use specified URL paths for sending and receiving files

Usually QRCP has default URL it uses to file transfer, which are:

http://{ip address}:{port}/send/{random path} for sending files and http://{ip address}:{port}/receive/{random path} for receiving files

If you want to set specific URL paths, use this command

http://{ip address}:{port}/send/abcd

Allow printing of QRCP QR code in a browser

By default, QRCP prints its QR code in the terminal. Incase you want to print it on a browser instead of the Terminal window, use:

qrcp --browser file.txt

Keep server alive after file transfer in QRCP

After file transfer, QRCP server stops automatically. To keep it alive, use this command:

qrcp --keep-alive file.txt

Specify a configuration file to be used by QRCP

QRCP stores its config file in a specified folder at /home/.qrcp.json. But if your config file is stored in a different folder, issue this command

qrcp --config ~/home/new file/qrcp.json file.txt

Get help In QRCP

There are many other flags QRCP uses. These can be displayed with this command

qrcp --help

Conclusion

In this guide we have successfully installed, configured and shared files using QRCP. We have demonstrated the different ways to both install and configure QRCP.

I hope this article was helpful. Please check some other articles on our website:

Securely Transfer Files and Folders between Two computers using Croc

LPIC 101 – Locating and Finding Files on Linux Filesystems

LEAVE A REPLY

Please enter your comment!
Please enter your name here