| 1 |
age-plugin-batchpass(1) -- non-interactive passphrase encryption plugin for age(1) |
| 2 |
================================================================================== |
| 3 |
|
| 4 |
## SYNOPSIS |
| 5 |
|
| 6 |
`age` `-e` `-j` `batchpass`<br> |
| 7 |
`age` `-d` `-j` `batchpass`<br> |
| 8 |
|
| 9 |
## DESCRIPTION |
| 10 |
|
| 11 |
`age-plugin-batchpass` is an age(1) plugin that enables non-interactive |
| 12 |
passphrase-based encryption and decryption using environment variables. |
| 13 |
|
| 14 |
## WARNING |
| 15 |
|
| 16 |
This functionality is not built into the age CLI because most applications |
| 17 |
should use native keys instead of scripting passphrase-based encryption. |
| 18 |
|
| 19 |
Humans are notoriously bad at remembering and generating strong passphrases. |
| 20 |
age uses scrypt to partially mitigate this, which is necessarily very slow. |
| 21 |
|
| 22 |
If a computer will be doing the remembering anyway, you can and should use |
| 23 |
native keys instead. There is no need to manage separate public and private |
| 24 |
keys, you encrypt directly to the private key: |
| 25 |
|
| 26 |
$ age-keygen -o key.txt |
| 27 |
$ age -e -i key.txt file.txt > file.txt.age |
| 28 |
$ age -d -i key.txt file.txt.age > file.txt |
| 29 |
|
| 30 |
Likewise, you can store a native identity string in an environment variable |
| 31 |
or through your CI secrets manager and use it to encrypt and decrypt files |
| 32 |
non-interactively: |
| 33 |
|
| 34 |
$ export AGE_SECRET=$(age-keygen) |
| 35 |
$ age -e -i <(echo "$AGE_SECRET") file.txt > file.txt.age |
| 36 |
$ age -d -i <(echo "$AGE_SECRET") file.txt.age > file.txt |
| 37 |
|
| 38 |
The age CLI also natively supports passphrase-encrypted identity files, so you |
| 39 |
can use that functionality to non-interactively encrypt multiple files such that |
| 40 |
you will be able to decrypt them later by entering the same passphrase: |
| 41 |
|
| 42 |
$ age-keygen -pq | age -p -o encrypted-identity.txt |
| 43 |
Public key: age1pq1cd[... 1950 more characters ...] |
| 44 |
Enter passphrase (leave empty to autogenerate a secure one): |
| 45 |
age: using autogenerated passphrase "eternal-erase-keen-suffer-fog-exclude-huge-scorpion-escape-scrub" |
| 46 |
$ age -r age1pq1cd[... 1950 more characters ...] file.txt > file.txt.age |
| 47 |
$ age -d -i encrypted-identity.txt file.txt.age > file.txt |
| 48 |
Enter passphrase for identity file "encrypted-identity.txt": |
| 49 |
|
| 50 |
Finally, when using this plugin care should be taken not to let the password be |
| 51 |
persisted in the shell history or leaked to other users on multi-user systems. |
| 52 |
|
| 53 |
## ENVIRONMENT |
| 54 |
|
| 55 |
* `AGE_PASSPHRASE`: |
| 56 |
The passphrase to use for encryption or decryption. |
| 57 |
Mutually exclusive with `AGE_PASSPHRASE_FD`. |
| 58 |
|
| 59 |
* `AGE_PASSPHRASE_FD`: |
| 60 |
A file descriptor number to read the passphrase from. |
| 61 |
Trailing newlines are stripped from the file contents. |
| 62 |
Mutually exclusive with `AGE_PASSPHRASE`. |
| 63 |
|
| 64 |
* `AGE_PASSPHRASE_WORK_FACTOR`: |
| 65 |
The scrypt work factor to use when encrypting. |
| 66 |
Must be between 1 and 30. Default is 18. |
| 67 |
Higher values are more secure but slower. |
| 68 |
The age CLI refuses to decrypt files above 22, and so does this plugin |
| 69 |
unless `AGE_PASSPHRASE_MAX_WORK_FACTOR` is set to at least the same value. |
| 70 |
|
| 71 |
* `AGE_PASSPHRASE_MAX_WORK_FACTOR`: |
| 72 |
The maximum scrypt work factor to accept when decrypting. |
| 73 |
Must be between 1 and 30. Default is 22. |
| 74 |
Can be used to avoid very slow decryptions, or to allow slower ones. |
| 75 |
|
| 76 |
## EXAMPLES |
| 77 |
|
| 78 |
Encrypt a file with a passphrase: |
| 79 |
|
| 80 |
$ AGE_PASSPHRASE=secret age -e -j batchpass file.txt > file.txt.age |
| 81 |
|
| 82 |
Decrypt a file with a passphrase: |
| 83 |
|
| 84 |
$ AGE_PASSPHRASE=secret age -d -j batchpass file.txt.age > file.txt |
| 85 |
|
| 86 |
Read the passphrase from a file descriptor: |
| 87 |
|
| 88 |
$ AGE_PASSPHRASE_FD=3 age -e -j batchpass file.txt 3< passphrase.txt > file.txt.age |
| 89 |
|
| 90 |
## SEE ALSO |
| 91 |
|
| 92 |
age(1) |
| 93 |
|
| 94 |
## AUTHORS |
| 95 |
|
| 96 |
Filippo Valsorda <[email protected]> |