Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

age

A small, modern file encryption tool with short keys — simpler than GPG, used by SOPS and for encrypted backups.

Level
DevSecOps service
Group
Secrets
Needs root
No
Package
age

What it does

age encrypts files to one or more recipients (public keys starting with age1…, or SSH public keys) or with a passphrase. There is no web of trust and no config. age-keygen makes a key pair. It is the default key type for SOPS in GitOps repos.

How to write it

age [-r RECIPIENT | -R FILE | -p] [-a] [-o OUT] [IN]
age -d [-i IDENTITY] [-o OUT] [IN]

Main parts

Tools

age-keygen [-o FILE]
Make a new key pair.
age-keygen -y FILE
Print the public key of a private key file.
age
Encrypt or decrypt.

Options 7

Most used

age flags

-r RECIPIENT
Encrypt for this public key (repeat for more).
-R FILE
Recipients from a file (also ~/.ssh/id_ed25519.pub).
-p
Use a passphrase.
-a
ASCII armor (text output).
-d
Decrypt.
-i FILE
Identity (private key) file for decrypting.
-o FILE
Output file.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Make a key pair

    age-keygen -o key.txt
    Public key: age1qz8x0examplepublickeyonly0000000000000000000000000000q9lc5
    chmod 600 key.txt
  2. 2Encrypt a file for a public key

    age -r age1qz8x0examplepublickeyonly0000000000000000000000000000q9lc5 -o backup.tar.gz.age backup.tar.gz
  3. 3Decrypt it

    age -d -i key.txt -o backup.tar.gz backup.tar.gz.age
  4. 4Encrypt for several people

    cat recipients.txt
    age1qz8x0examplepublickeyonly0000000000000000000000000000q9lc5
    ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyOnly admin@laptop
    age -R recipients.txt -o db.sql.age db.sql
  5. 5Use your SSH key to decrypt

    age -d -i ~/.ssh/id_ed25519 db.sql.age > db.sql
  6. 6Encrypt with a passphrase

    age -p -o notes.txt.age notes.txt
  7. 7Encrypt a backup on the fly

    tar czf - /etc | age -r age1qz8x0examplepublickeyonly0000000000000000000000000000q9lc5 > etc-$(date +%F).tgz.age
  8. 8Text output to paste

    echo "token=abc" | age -a -r age1qz8x0examplepublickeyonly0000000000000000000000000000q9lc5
  9. 9Show the public key of a key file

    age-keygen -y key.txt
  10. 10Decrypt and restore a backup

    age -d -i key.txt etc-2026-10-27.tgz.age | tar tzf - | head

Watch out

  • Lose the private key = lose the data. Keep an offline backup of key.txt.
  • age does not sign; it only encrypts. Use ssh-keygen -Y sign, minisign or cosign for signatures.

Files

key.txt
Private key (AGE-SECRET-KEY-1…). Keep it secret.

Tips to remember

  • For many secrets in Git, use SOPS with age instead of encrypting whole files.

Exit codes

0Success.
1Error (wrong key, bad file).

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man age