Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
age-keygen -o ~/.config/age/key.txt
Public key: age1examplepublickeyexamplepublickeyexamplepublickeyxx
age -r age1examplepublickeyexamplepublickeyexamplepublickeyxx -o dump.sql.age dump.sql
age -d -i ~/.config/age/key.txt -o dump.sql dump.sql.age
gpg -c --cipher-algo AES256 report.pdf
gpg -d report.pdf.gpg > report.pdf-r = encrypt for a public key (only the owner of the private key can open it); gpg -c = with a passphrase.
Step by step
- Install:
dnf install age gnupg2(age from EPEL on RHEL) orapt-get install age gnupg. - age with keys — each person makes a key pair once, and shares only the public key (
age1…):
mkdir -p ~/.config/age && (umask 077; age-keygen -o ~/.config/age/key.txt)
age -r age1alice… -r age1bob… -o shop-db.sql.age shop-db.sqlSeveral -r = several people can open it. age can also use SSH keys: age -R ~/.ssh/id_ed25519.pub …, and open with age -d -i ~/.ssh/id_ed25519 ….
- age with a passphrase (no keys — for a one-time exchange):
age -p -o notes.txt.age notes.txtSend the passphrase over another channel (phone, Signal), not in the same email.
- GPG with a person's public key (companies with GPG keys):
gpg --import alice.asc
gpg --list-keys alice@example.com
gpg --encrypt --recipient alice@example.com --output report.pdf.gpg report.pdf
gpg --decrypt --output report.pdf report.pdf.gpg- A whole folder — pack and encrypt in one stream (no plain archive on disk):
tar -czf - ./exports | age -r age1alice… > exports.tar.gz.age
age -d -i ~/.config/age/key.txt exports.tar.gz.age | tar -xzf -- Remove the plain file after you checked the encrypted one opens:
shred -u dump.sql(On SSDs and copy-on-write file systems shred is not a guarantee — better never write the plain file at all, like in step 5.)
- Keys are everything: lose the private key or passphrase = lose the data. Keep a backup of the key in a safe place (password manager, offline). For secrets in Git use SOPS (built on age/GPG).
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
age: error: no identity matched any of the recipients | Wrong key file for this file. | Use the private key that matches the -r used for encryption. |
| GPG asks for the passphrase but no prompt appears (SSH) | pinentry can not find the terminal. | export GPG_TTY=$(tty). |
gpg: … No public key | The recipient's key is not imported. | gpg --import KEY.asc; check the fingerprint with the person. |
gpg: … There is no assurance this key belongs to the named user | Key not trusted/signed. | Verify the fingerprint, then sign or trust it. |
age: command not found on RHEL | Not in the base repos. | Enable EPEL. |
| Encrypted file can never be opened | Lost key or passphrase. | No recovery — back up keys; encrypt for two recipients (you + a backup key). |
Go further
- Command pages: gpg, age, tar.
- Next how-tos: Generate a strong password or secret, Create a Kubernetes Secret safely, Back up a server with restic.
- Full guide: SOPS (encrypted secrets in Git). At work: age, gpg.
1You must send a database dump to two colleagues with age. How?
age -r PUBKEY1 -r PUBKEY2 -o dump.sql.age dump.sql — each can open it with their own private key.
2What happens if you lose the age private key?
The files encrypted only for it can never be opened again.