Charly's Column – Age
Charly's Column – Age
Charly makes life easier for himself by using the lean Age tool for command-line data encryption tasks.
Age (think "aghe" in "spaghetti") promises an uncomplicated approach to encrypting and decrypting files. Written in Go, both the source code and precompiled binaries for various platforms can be found on GitHub [1]. I tried Age on a Raspberry Pi, but the tool also runs on Linux on a PC, macOS, and Windows. The author says the current release from mid-June 2021 is "maybe actually the last v1.0.0 release candidate."
Age supports two ways to encrypt and decrypt files. With the first option, you can create a key file (Age calls this an identity file) based on SSH keys with whose contents you then encrypt the data. In contrast to SSH, this is a symmetrical procedure, so the same file is also used for decryption.
As a second option, Age lets you use a passphrase to encrypt the data. This has the advantage that you can think up a new passphrase for each encryption process. A person you trust and give a passphrase to can use it to decrypt your data – but only the data you encrypted with precisely that one passphrase.
Let's look at both methods. By way of an example, I copied the file /etc/passwd
to my home directory and will now encrypt it using both methods in turn. For the key file method, I need to generate the key file first – I can do this with age-keygen
(Figure 1).
The next step is to encrypt the passwd
file with the key I just generated (Listing 1, line 2). This creates the encrypted passwd.age
file. To decrypt it, use the command from the line 3 of Listing 1.
Listing 1
Key Method
01 $ age-keygen -o age-key.txt 02 $ age --encrypt -i age-key.text -o passwd.age ./passwd 03 $ age --decrypt -i age-key.text -o passwd passwd.age
Now I'll do the same thing but with the passphrase method. Again, I encrypt the passwd
file and give it the name passwd.age
. After the corresponding call shown in line 1 of Listing 2, Age asks me for the desired passphrase. If I don't enter one, the tool generates one itself. Decryption works in the same way, but you can leave out the --passphrase
parameter here (line 4).
Listing 2
Passphrase Method
01 $ age --passphrase -o passwd.age passwd 02 Enter passphrase (leave empty to autogenerate a secure one): 03 Using the autogenerated passphrase "release-response-step-brand-wrap-ankle-pair-unusual-sword-train". 04 $ age --decrypt -o passwd passwd.age 05 Enter passphrase:
The entire procedure's security relies, of course, on careful handling of the key or the passphrase.
Infos
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
First Release Candidate for Linux Kernel 6.14 Now Available
Linus Torvalds has officially released the first release candidate for kernel 6.14 and it includes over 500,000 lines of modified code, making for a small release.
-
System76 Refreshes Meerkat Mini PC
If you're looking for a small form factor PC powered by Linux, System76 has exactly what you need in the Meerkat mini PC.
-
Gnome 48 Alpha Ready for Testing
The latest Gnome desktop alpha is now available with plenty of new features and improvements.
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.