feat(kv)!: take KID:KEY pairs and key files as kv add arguments with optional --service and --vault

This commit is contained in:
imSp4rky
2026-12-04 23:19:52 -07:00
parent f10b8dcf99
commit deb4b7846d
4 changed files with 171 additions and 35 deletions
+11 -3
View File
@@ -460,9 +460,16 @@ A vault argument is the name of a vault in the config, or the path to an SQLite
Make sure that two or more vaults hold the same set of content keys, essentially a chained bidirectional copy. More than one vault is necessary. Accepts the same `--service` / `--local-only` options as `copy`.
### `kv add FILE SERVICE VAULT...`
### `kv add KEY...`
Add content keys to one or more vaults for a service. `FILE` contains one `KID:KEY` pair per line (32 hex : 32 hex, UTF-8). unshackle skips every line that does not match that form.
Add content keys to vaults. Each `KEY` is a `KID:KEY` pair (32 hex : 32 hex; unshackle removes dashes from the KID), or the path of a UTF-8 file with one `KID:KEY` pair per line. unshackle skips every file line that is not a pair. An argument that is not a pair or an existing file stops `kv add` with an error.
unshackle sends the content keys to each vault, also when another vault already holds them, and reports how many each vault already held.
| Option | Description |
|---|---|
| `-s`, `--service` | The service to add the content keys to. Without it, unshackle writes them to the `generic` table. |
| `-v`, `--vault` | A vault name from the config, or the path to an SQLite vault file. Repeat it for more vaults. Without it, unshackle writes to every configured vault that does not set `no_push`. |
### `kv search KID`
@@ -485,7 +492,8 @@ unshackle kv copy main backup1 backup2
unshackle kv copy main backup -s EXAMPLE
unshackle kv copy main ~/Downloads/key_store.db -s EXAMPLE
unshackle kv sync main mysql_vault
unshackle kv add keys.txt EXAMPLE main backup
unshackle kv add 0123456789abcdef0123456789abcdef:fedcba9876543210fedcba9876543210
unshackle kv add keys.txt -s EXAMPLE -v main -v backup
unshackle kv search 0123456789abcdef0123456789abcdef -s EXAMPLE -v main
unshackle kv prepare main mysql_vault
```
+5 -4
View File
@@ -188,12 +188,13 @@ The `kv` command group manages the contents of your configured vaults. Every sub
$ unshackle kv --help
```
### `kv add`: import keys from a file
### `kv add`: add content keys
Add `KID:KEY` pairs to one or more vaults for a given service. The file must contain one pair per line as `HEX:HEX` (32 hex characters each); lines that do not match are ignored.
Add `KID:KEY` pairs to your vaults, for a service or in the `generic` table. Give each pair on the command line, or give a file with one pair per line. The options are in the [CLI reference](cli-reference.md#kv-add-key).
```console
$ unshackle kv add keys.txt EXAMPLE local shared
$ unshackle kv add 9a04f07998404286ab92e65be0885f95:b1c2d3e4f5a6978012345678deadbeef
$ unshackle kv add keys.txt -s EXAMPLE -v local -v shared
```
```text title="keys.txt"
@@ -201,7 +202,7 @@ $ unshackle kv add keys.txt EXAMPLE local shared
0e7cc1a4e2f9411db0f24a3fbb8f8b21:00112233445566778899aabbccddeeff
```
The service argument (`EXAMPLE` above) is normalised to its canonical tag automatically. Keys that already exist in a vault are reported as skipped.
The service (`EXAMPLE` above) is normalised to its canonical tag automatically. Keys that already exist in a vault are reported as skipped. The other vaults still receive them.
If a vault answers and refuses the content keys, `kv add` shows one warning and continues with the next vault. If a vault is unreachable or still rate limited, `kv add` stops with an error.