Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
yage: yaml age
A simple tool to manage encrypted secrets in YAML files with age encryption.
yage is using age encryption to encrypt the values
in a YAML file while keeping the keys unchanged.
A simple yaml file like this one:
backend:
url: https://example.com
username: gaspard
password: api_s3cr3t_k3y
is encrypted by yage to:
backend:
url: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBtNGppeGdDRUJiVm9JcE9iTG1KYWxzWmx1Um1IVEVXTmx5WkhEVmk1TmpBCnh5b05IYzZOdUc3cG5qTElIei9LVmZJQk1sZkZFQUJncXRxc2huWXVRSzAKLT4gKmUtZ3JlYXNlIGBOTjkgIUY8UClwTXUKZU9oaVp5cjUrR2NENDN5UEJJbDJTeVU0UllJcjAyRTFySXVXdDQzU2poaVJJZ3EvQy9UMFk5UHdxNFAyK2VXRwpTTDYwOFlQM1ptem5qMzgxclREUVpQWERXbXp4elB0ck9UczJvNTlEVk1SdjM5b1MvZmNrN3p1Q0I0QTlLMThJCmIrOTMKLS0tIHNFNXpPT2VnblZKVCtTZTR2dmFDT3VzeE1WSFdzamtBTzQ0aGM1U2RCSjAKfS0+H2nU0KZ5EscjEXOhcth+2tTaXm33uKZcWMB9+P2p1fn2+SdO9FlH7rGDn2lo8mq7Yg==]
username: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBDUjV1STI5Y2JLK3V4ZjlEeTg3aWNpVFl2UVJKcVpoL0dwTTVzdnNRZ0dNClpGM214MkIwQlhWdG0yeG8zcWFNM2lxeW5qWEY2cENVVTlLK2lyQWh1SFUKLT4gQVBDU2k1LWdyZWFzZSBnVjBgICcmUjIgOXs/a29+cyBAInBKTjkvPgo2ODN5bEttVGxlNE1nSTlPRVFGQzNnT0pneWU4cnkwdzRXaC9UT21LZS81TzNiSTZSMVRZVVBuWUJMcjNnMjhUCmQvenZvTWRRRUhjTDBvUksvZlN0RTlxRmpGVE5EcVV2ME1TNTVpT2lCKzNEUmtPRmNySkR2dHRTdncKLS0tIGxqbDNtTktPNmxWV25zd2V2MGpMRE8yOUx4Rm0zdmltZk9JRTdmQ29MTFEKZHImd+aw9OcLyHAPvBUyhDy/9bkupIKFOhkO/MYD6IoOtKly1fQqTA==]
password: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB2eXFiMTFMV1ZpTTh6QVQzRUo0anI3TVUxVEJTNE01UW1xcEFvdHJZcVFJClNyNllQT2hmM0lwWldXZllHWGtUQ3JZeW1sOHJ0b2Vabk5YZ3o5a2dOeG8KLT4gfC1ncmVhc2UgMSBEbyFqMyAiT2YnIk80Cnp1WVFoTkxSaGc2dXNOaGpRWGVRNkU0WlFHeUhzd0UKLS0tIERHNmN3WldFcHhpTmczdzhGOVF0bld1ZHQxbi8yY3o5b2F4ZExUU0l6OFkKq01qW5HZMk5O/tHAMP4ezAeb38DX0+8vle29hNpZvoVLSw/wsHu0yNlcp053kFQ=]
Having the keys unencrypted allows to easily manage the file in a version control system, like git, and to use this file in a CI/CD pipeline or in a gitops workflows.
If you think this looks a lot like SOPS, you're right! This is basically what SOPS is doing, but we some key differences:
yagedoesn't include any metadata in the encrypted file, in particular no MAC.yageis focused on age encryption, and include everything required in a single binary.
The lack of MAC, while it could be seen as a missed opportunity to add some security, actually allows some interesting use cases:
- the encrypted file can modified by someone that only has the public key, while still preserving the encrypted values.
- the encrypted file can modified by multiple persons and merged in a version control system without having to decrypt it first.
- the encrypted file only contains the original keys and the encrypted values, so it can be used to verify that it is usable for a specific task without having to decrypt it or remove the metadata.
Installation
Only available from source for now. More to come soon!
From source
Just run
in this repository
Command line reference
yage comes with a full description of its commands and options. Just run yage --help to get it.
)
See also the markdown version of the command line reference.
You may also find convenient to install the completion for your shell. For example for fish:
Usage
First generate a new age key pair:
The public key can be shared with anyone. It allows everybody that has that key to encrypt a secret that can be decrypted only by someone who has access to the private key. The private key must be kept secret.
Both keys are just text:
The public key could be committed to a git repository:
Make sure that the private key won't be committed by mistake in the repository, for example by adding it
to the .gitignore file, and by using a tool like gitleaks.
$ echo "*.key" > .gitignore
The private key should be kept in a secure place, for example in a password manager. It may also be added to a CI/CD pipeline as a secret.
Once you have a private and a public key, you can encrypt a YAML file. The --recipient-file or -R
option is used to specify a file containing the public keys to use for encryption. The recipients
can also be specified directly on the command line with the --recipient or -r option.
If you prefer you can encrypt the file in place wit the --in-place or -i option:
You need the private key to have access to the decrypted values, so if you don't have it,
the encrypted file is showing you what is encrypted, for example backend.password, but not the values.
backend:
password: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB2eXFiMTFMV1ZpTTh6QVQzRUo0anI3TVUxVEJTNE01UW1xcEFvdHJZcVFJClNyNllQT2hmM0lwWldXZllHWGtUQ3JZeW1sOHJ0b2Vabk5YZ3o5a2dOeG8KLT4gfC1ncmVhc2UgMSBEbyFqMyAiT2YnIk80Cnp1WVFoTkxSaGc2dXNOaGpRWGVRNkU0WlFHeUhzd0UKLS0tIERHNmN3WldFcHhpTmczdzhGOVF0bld1ZHQxbi8yY3o5b2F4ZExUU0l6OFkKq01qW5HZMk5O/tHAMP4ezAeb38DX0+8vle29hNpZvoVLSw/wsHu0yNlcp053kFQ=]
But with just the public key, you can still modify the file, for example to add a new secret:
mail:
apiKey: my_secret_key_to_send_emails
backend:
password: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB2eXFiMTFMV1ZpTTh6QVQzRUo0anI3TVUxVEJTNE01UW1xcEFvdHJZcVFJClNyNllQT2hmM0lwWldXZllHWGtUQ3JZeW1sOHJ0b2Vabk5YZ3o5a2dOeG8KLT4gfC1ncmVhc2UgMSBEbyFqMyAiT2YnIk80Cnp1WVFoTkxSaGc2dXNOaGpRWGVRNkU0WlFHeUhzd0UKLS0tIERHNmN3WldFcHhpTmczdzhGOVF0bld1ZHQxbi8yY3o5b2F4ZExUU0l6OFkKq01qW5HZMk5O/tHAMP4ezAeb38DX0+8vle29hNpZvoVLSw/wsHu0yNlcp053kFQ=]
You can encrypt the new secrets by just using the same command as before:
secrets.yaml now contains the encrypted values:
mail:
apiKey: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBWbnRCSVhYWmNKaUg1QUgwSjFOK0JITWdkdktXT2wwbmtIOExrTE5rWG53ClpwOE5WYzdTZnBZandnM2RyVzFMNDRkQTFBL281WE5URW55bytUYk5mdFkKLT4gezdgcUA2WiMtZ3JlYXNlIF9CTDFAcE4/CkRFVzU0Vmt6RDBtdnhoZldhQmJld2JuMDUzVnNGRkczYTJEVnF0TWVWTmdmcit4TDFzU1pTYTh6NW51cDlRNmwKQ3cKLS0tIGx1Rm1BNlpFejNDSm0rejVSRGJIQjlUS3hOTXFBd2dRcXE1eFhTUjAwRGsKe59C1Is1S3EEEvxyqaVz4ZLWbheaa/i7xDv6fJAC2AkFmLGRd0VuhcPK3AUpy2V64MQrVmmGTZabt2Jc1w==]
backend:
password: yage[YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB2eXFiMTFMV1ZpTTh6QVQzRUo0anI3TVUxVEJTNE01UW1xcEFvdHJZcVFJClNyNllQT2hmM0lwWldXZllHWGtUQ3JZeW1sOHJ0b2Vabk5YZ3o5a2dOeG8KLT4gfC1ncmVhc2UgMSBEbyFqMyAiT2YnIk80Cnp1WVFoTkxSaGc2dXNOaGpRWGVRNkU0WlFHeUhzd0UKLS0tIERHNmN3WldFcHhpTmczdzhGOVF0bld1ZHQxbi8yY3o5b2F4ZExUU0l6OFkKq01qW5HZMk5O/tHAMP4ezAeb38DX0+8vle29hNpZvoVLSw/wsHu0yNlcp053kFQ=]
Note that backend.password has not been re-encrypted, so you can easily track the changes in your
version control system.
To decrypt the file, you need the private key:
Or just do it in place:
If your decrypting in a CI/CD pipeline, you may find convenient to put the private key in the
YAGE_KEY environment variable. This way you can just use yage decrypt -i secrets.yaml.
If you have the private key, you can edit the file in place with your favorite text editor
configured in the EDITOR environment variable:
The file is edited in clear in the editor and re-encrypted when you save and quit. Here again only the modified values are re-encrypted. The others are left unchanged to allow easy tracking of changes.
Finally, with the private key, you can use the secrets in the encrypted file to run a command with the environment variables set to the decrypted values in a single command:
Why?
Mostly to unlock the ability to add values to an encrypted file without having to decrypt it, thing that is not possible with SOPS. Something I've not been the only one frustrated with, see here, here, here, here, …
And because writing command line tools in rust is fun!
Still to be done
- Add tests. Coming soon!
- Add a status command to ensure the whole file is encrypted/decrypted
- Support comments. Sadly no YAML library that I know of supports comments, so this will be a bit tricky.
License
yage is distributed under the terms of the MIT license.
See LICENSE for details.