The rage command line tool is a Rust implementation of the age encryption tool, which is designed for simple, secure, and modern encryption of files. This tutorial demonstrates how to install rage command for encrypting files on Ubuntu 24.04.
Instal rage
Get the newest version of rage from GitHub and assign it to a variable:
RAGE_VERSION=$(curl -s "https://api.github.com/repos/str4d/rage/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
Download rage utilizing the previously identified version:
wget -qO rage.tar.gz https://github.com/str4d/rage/releases/latest/download/rage-v$RAGE_VERSION-x86_64-linux.tar.gz
Extract rage and rage-keygen commands to /usr/local/bin directory:
sudo tar xf rage.tar.gz --strip-components=1 -C /usr/local/bin rage/rage rage/rage-keygen
We can check rage version as follows:
rage --version
Remove tar.gz file:
rm -rf rage.tar.gz
Testing rage
Create text file for testing:
echo 'Testing' > data.txt
The rage-keygen tool generates a pair of keys: a private key and a public key. The public key encrypts data, while the private key decrypts it.
rage-keygen -o key.txt
This command produces a key.txt file with the public key and private key inside.
cat key.txt
Example:
# created: 2024-07-29T07:47:20+03:00
# public key: age1umsejwtl8760klqgmz9x57902kuu6p9552a907lyw4cv7wctu3dse9h7cs
AGE-SECRET-KEY-1JSHTXAX8W5Z0DVAU5SNQ9ZAF0Q859CJ3NFG043RHMW0Y990WFZPQGX5Q2H
Execute the rage command to encrypt a file using the public key:
rage -r age1umsejwtl8760klqgmz9x57902kuu6p9552a907lyw4cv7wctu3dse9h7cs data.txt > data.txt.age
Now, decrypt the encrypted file with the private key located in the key.txt file:
rage -d -i key.txt data.txt.age > data_decrypted.txt
Uninstall rage
In case you want to completely uninstall rage, delete the listed files:
sudo rm -rf /usr/local/bin/rage
sudo rm -rf /usr/local/bin/rage-keygen
Leave a Comment
Cancel reply