YB-FORMAT(1)
πΈ YB-FORMAT(1) β the format girlies' era begins πΈ
okay so real talk, this is the format page from the yb manual fam β section 1, User Commands, bestie. sit down, grab a strawberry drink π, and let's get your YubiKey ready.
β¨ NAME β¨
format β provisions PIV objects and, if you want, generates an ECDH key too π
π SYNOPSIS π
format [-c|--object-count] [-k|--key-slot] [-g|--generate]
[-n|--subject] [--protect] [--yes] [--plan] [-h|--help]
π¦ DESCRIPTION π¦
So like, format is the glow-up your YubiKey needs before it can hang out with yb(1). It writes a brand-new store header and allocates COUNT PIV data objects. Heads up though: any existing yb data on the card gets erased, no cap, gone, bye π. Each object is written at exactly the size its content needs β 9-byte sentinel for empty slots, up to 3,063 bytes for occupied ones. Efficient queen behavior π
If you run format from a terminal with no format options at all, you get the guided experience and honestly? it's giving personal assistant. It shows you the state of the YubiKey (literally exactly like yb fsck does), changes a factory-default PIN and PUK, keeps or replaces the key in slot 0x82, always keeps the management key on the YubiKey (unlocked by the PIN, so that writes need only the PIN), shows you the plan, and asks for confirmation before writing anything. And when the plan is about to destroy blobs or an existing key? The confirmation is the YubiKey's serial number. Like, type the serial, prove you mean it π«Ά.
Any format option β or --yes β switches you to the flag-driven mode described below, and so does running without a terminal. yb format --yes formats with the defaults, no prompting, out the door π¨.
By default, format expects an ECDH key to already exist in the chosen PIV slot, and it checks that it matches the slot's X.509 certificate. Want a fresh one? Pass --generate and it creates a new P-256 key pair plus a self-signed certificate, right on the card β¨.
Pass --protect to keep the management key on the YubiKey, unlocked by the PIN. If it's not kept there, it gets replaced with a random key stored in the PRINTED PIV object β which only the PIN unlocks. If it already is kept there, it stays. This is such a convenience: you no longer need to keep the management key yourself π. After this, future write operations only require the PIN β no YB_MANAGEMENT_KEY or --key needed, periodt. The current management key is taken from YB_MANAGEMENT_KEY / --key, else from PRINTED if the card is already protected, else the factory default.
Pass --plan to run the checks and print the plan without writing anything. Important vibe check: --plan does talk to the YubiKey and verifies the PIN β and it exits with status 1, with the error the real command would give, when a check fails. It's a dress rehearsal, not a fake one π.
Here's the order of operations, because the order is iconic: format first checks everything it can without writing (PIN, management key, slot key) and lists the blobs it's gonna destroy. Then it sets up protection, erases the store, and generates the key last β so a failure never leaves blobs behind a replaced key. If it stops partway through, the message tells you what was done and what to run next. Thoughtful and communicative, we love to see it π.
π¨ real one:formatmust be run once beforestore,fetch, or any other command that accesses the store. no format, no store. that's the rule.
π OPTIONS π
-c,--object-count<OBJECT_COUNT>β how many PIV objects to allocate (1β32) [default:32]-k,--key-slot<KEY_SLOT>β PIV slot for the ECDH encryption key (decimal or0x-prefixed hex) [default:0x82]-g,--generateβ generate a new EC key pair in the chosen slot β¨-n,--subject<SUBJECT>β X.509 subject for the self-signed certificate (only with--generate) [default:/CN=YBLOB ECCP256]--protectβ keep the management key on the YubiKey, unlocked by the PIN.
If it's not kept there, replace it with a random key stored in the PRINTED object, which only the PIN unlocks, so that future write operations only require the PIN. If it already is, keep it. The current management key is taken from YB_MANAGEMENT_KEY, else from PRINTED if the YubiKey is already protected, else the factory default.
--yesβ format without the guided flow, even from a terminal: keep the key in the slot,32objects, no protection (unless other flags say otherwise)--planβ run the checks and show what the format would do, then stop.
Talks to the YubiKey (and verifies the PIN) but writes nothing. π«Ά
-h,--helpβ print help (see a summary with-h)
π EXAMPLES π
First-time setup, guided:
yb format
First-time setup from a script β generate a key, format, and keep the management key on the YubiKey:
yb format --generate --protect
Show what that would do, without writing anything:
yb format --generate --protect --plan
First-time setup, keeping the management key yourself:
yb format --generate
Compact store (10 objects) in slot 0x83:
yb format -c 10 -k 0x83 --generate
Re-format using an existing key in slot 0x9D:
yb format -k 0x9D
π SEE ALSO π
yb(1), yb-store(1), yb-fsck(1), ykman(1) β go read the whole fam, iykyk π
that's the whole page bestie, go format something gorgeous π₯ β this was yb, 2026-03, page YB-FORMAT(1) (section 1, User Commands), signing off with a π and a π
fr fr
π¦ where this page comes from
- nixpkgs unstable: yb 0.5.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms