@@ -203,6 +203,22 @@ can use the example files and pgp key provided with the repository:
203203
204204This last step will decrypt ` example.yaml` using the test private key.
205205
206+ # # Encrypting with GnuPG subkeys
207+
208+ If you want to encrypt with specific GnuPG subkeys, it does not suffice to provide the
209+ exact key ID of the subkey to SOPS, since GnuPG might use * another* subkey instead
210+ to encrypt the file key with. To force GnuPG to use a specific subkey, you need to
211+ append ` ! ` to the key' s fingerprint.
212+
213+ ``` yaml
214+ creation_rules:
215+ - pgp: >-
216+ 85D77543B3D624B63CEA9E6DBC17301B491B3F21!,
217+ E60892BB9BD89A69F759A1A0A3D652173B763E8F!
218+ ```
219+
220+ Please note that this is only passed on correctly to GnuPG since SOPS 3.9.3.
221+
206222## Encrypting using age
207223
208224[age](https://age-encryption.org/) is a simple, modern, and secure tool
@@ -234,6 +250,28 @@ decrypt the data.
234250
235251Encrypting with SSH keys via age is not yet supported by SOPS.
236252
253+ A list of age recipients can be added to the ` .sops.yaml` :
254+
255+ ` ` ` yaml
256+ creation_rules:
257+ - age: > -
258+ age1s3cqcks5genc6ru8chl0hkkd04zmxvczsvdxq99ekffe4gmvjpzsedk23c,
259+ age1qe5lxzzeppw5k79vxn3872272sgy224g2nzqlzy3uljs84say3yqgvd0sw
260+ ` ` `
261+
262+ It is also possible to use ` updatekeys` , when adding or removing age recipients. For example:
263+
264+ ` ` ` sh
265+ $ sops updatekeys secret.enc.yaml
266+ 2022/02/09 16:32:02 Syncing keys for file /iac/solution1/secret.enc.yaml
267+ The following changes will be made to the file' s groups:
268+ Group 1
269+ age1s3cqcks5genc6ru8chl0hkkd04zmxvczsvdxq99ekffe4gmvjpzsedk23c
270+ +++ age1qe5lxzzeppw5k79vxn3872272sgy224g2nzqlzy3uljs84say3yqgvd0sw
271+ Is this okay? (y/n):y
272+ 2022/02/09 16:32:04 File /iac/solution1/secret.enc.yaml synced with new keys
273+ ```
274+
237275## Encrypting using GCP KMS
238276
239277GCP KMS uses [Application Default
@@ -689,6 +727,9 @@ stored under a specific directory, like a `git` repository, you can
689727create a ` .sops.yaml` configuration file at the root directory to define
690728which keys are used for which filename.
691729
730+ Note: The file needs to be named ` .sops.yaml` . Other names (i.e. ` .sops.yml` ) won' t be automatically
731+ discovered by sops. You' ll need to pass the ` --config .sops.yml` option for it to be picked up.
732+
692733Let\' s take an example:
693734
694735- file named ** something.dev.yaml** should use one set of KMS A, PGP
@@ -1514,6 +1555,24 @@ The value must be formatted as json.
15141555$ sops set ~ /git/svc/sops/example.yaml ' ["an_array"][1]' ' {"uid1":null,"uid2":1000,"uid3":["bob"]}'
15151556` ` `
15161557
1558+ # # Unset a sub-part in a document tree
1559+
1560+ Symmetrically, SOPS can unset a specific part of a YAML or JSON document, by providing
1561+ the path in the ` unset` command. This is useful to unset specific values, like keys, without
1562+ needing an editor.
1563+
1564+ ` ` ` sh
1565+ $ sops unset ~ /git/svc/sops/example.yaml ' ["app2"]["key"]'
1566+ ` ` `
1567+
1568+ The tree path syntax uses regular python dictionary syntax, without the
1569+ variable name. Set to keys by naming them, and array elements by
1570+ numbering them.
1571+
1572+ ` ` ` sh
1573+ $ sops unset ~ /git/svc/sops/example.yaml ' ["an_array"][1]'
1574+ ` ` `
1575+
15171576# # Showing diffs in cleartext in git
15181577
15191578You most likely want to store encrypted files in a version controlled
@@ -1597,10 +1656,20 @@ will not encrypt the values under the `description` and `metadata` keys
15971656in a YAML file containing kubernetes secrets, while encrypting
15981657everything else.
15991658
1659+ For YAML files, another method is to use ` --encrypted-comment-regex` which will
1660+ only encrypt comments and values which have a preceding comment matching the supplied
1661+ regular expression.
1662+
1663+ Conversely, you can opt in to only left certain keys without encrypting by using the
1664+ ` --unencrypted-comment-regex` option, which will leave the values and comments
1665+ unencrypted when they have a preeceding comment, or a trailing comment on the same line,
1666+ that matches the supplied regular expression.
1667+
16001668You can also specify these options in the ` .sops.yaml` config file.
16011669
1602- Note: these four options ` --unencrypted-suffix` , ` --encrypted-suffix` ,
1603- ` --encrypted-regex` and ` --unencrypted-regex` are mutually exclusive and
1670+ Note: these six options ` --unencrypted-suffix` , ` --encrypted-suffix` ,
1671+ ` --encrypted-regex` , ` --unencrypted-regex` , ` --encrypted-comment-regex` ,
1672+ and ` --unencrypted-comment-regex` are mutually exclusive and
16041673cannot all be used in the same file.
16051674
16061675# Encryption Protocol
0 commit comments