@@ -17,14 +17,50 @@ import (
1717const usage = `age-plugin-batchpass is an age plugin that enables non-interactive
1818passphrase-based encryption and decryption using environment variables.
1919
20- It is not built into the age CLI because most applications should use
21- native keys instead of scripting passphrase-based encryption.
20+ WARNING:
21+
22+ This functionality is not built into the age CLI because most applications
23+ should use native keys instead of scripting passphrase-based encryption.
24+
25+ Humans are notoriously bad at remembering and generating strong passphrases.
26+ age uses scrypt to partially mitigate this, which is necessarily very slow.
27+
28+ If a computer will be doing the remembering anyway, you can and should use
29+ native keys instead. There is no need to manage separate public and private
30+ keys, you encrypt directly to the private key:
31+
32+ $ age-keygen -o key.txt
33+ $ age -e -i key.txt file.txt > file.txt.age
34+ $ age -d -i key.txt file.txt.age > file.txt
35+
36+ Likewise, you can store a native identity string in an environment variable
37+ or through your CI secrets manager and use it to encrypt and decrypt files
38+ non-interactively:
39+
40+ $ export AGE_SECRET=$(age-keygen)
41+ $ age -e -i <(echo "$AGE_SECRET") file.txt > file.txt.age
42+ $ age -d -i <(echo "$AGE_SECRET") file.txt.age > file.txt
43+
44+ The age CLI also natively supports passphrase-encrypted identity files, so you
45+ can use that functionality to non-interactively encrypt multiple files such that
46+ you will be able to decrypt them later by entering the same passphrase:
47+
48+ $ age-keygen -pq | age -p -o encrypted-identity.txt
49+ Public key: age1pq1cd[... 1950 more characters ...]
50+ Enter passphrase (leave empty to autogenerate a secure one):
51+ age: using autogenerated passphrase "eternal-erase-keen-suffer-fog-exclude-huge-scorpion-escape-scrub"
52+ $ age -r age1pq1cd[... 1950 more characters ...] file.txt > file.txt.age
53+ $ age -d -i encrypted-identity.txt file.txt.age > file.txt
54+ Enter passphrase for identity file "encrypted-identity.txt":
55+
56+ Finally, when using this plugin care should be taken not to let the password be
57+ persisted in the shell history or leaked to other users on multi-user systems.
2258
2359Usage:
2460
25- AGE_PASSPHRASE=password age -e -j batchpass file.txt > file.txt.age
61+ $ AGE_PASSPHRASE=password age -e -j batchpass file.txt > file.txt.age
2662
27- AGE_PASSPHRASE=password age -d -j batchpass file.txt.age > file.txt
63+ $ AGE_PASSPHRASE=password age -d -j batchpass file.txt.age > file.txt
2864
2965Alternatively, you can use AGE_PASSPHRASE_FD to read the passphrase from
3066a file descriptor. Trailing newlines are stripped from the file contents.
0 commit comments