The public binary is piv.
It is designed around token tasks rather than raw APDU sequences. The default flow is: discover a reader, inspect the token, perform a targeted operation, and only then drop into expert diagnostics if required.
deviceslists readers and whether a card appears PIV-ready.infoshows a summary of the selected token.slotinspects slot state.certexports, imports, or deletes slot certificates.keygenerates, exports, deletes, signs, or challenges with slot keys.pin,puk, andmgmmanage credentials.setupcontains destructive initialization and reset flows.doctorruns safe environment and token readiness checks.diagcontains expert diagnostics such as object reads, TLV decoding, and raw APDU sends.configstores CLI-layer defaults.versionprints build information.
--readerselects a PC/SC reader by name.--adapteroverrides adapter auto-detection.--jsonemits machine-readable JSON to stdout.--non-interactivedisables prompts and interactive selection.--timeoutsets the command timeout.--traceand--trace-filecontrol diagnostic trace output.--verboseenables additional human-readable detail.--colorcontrols color policy.
When --json is enabled, stdout is reserved for JSON only. Human-facing notes, warnings, prompts, and trace output go to stderr.
List readers and PIV readiness:
piv devicesInspect one token:
piv info --reader "YubiKey 5C NFC"
piv slot show auth --reader "YubiKey 5C NFC"Export public artifacts:
piv cert export auth --reader "YubiKey 5C NFC" --out auth-cert.pem
piv key public auth --reader "YubiKey 5C NFC" --out auth-pub.pemUse credentialed operations safely:
piv pin verify --reader "YubiKey 5C NFC"
piv mgm rotate --reader "YubiKey 5C NFC" --dry-run
piv setup reset --reader "YubiKey 5C NFC" --dry-runFor piv key sign, the CLI resolves best-effort key metadata before deciding
whether to call VERIFY PIN.
- If the slot policy is known to require PIN verification, the CLI performs
VERIFYbefore signing. - If the slot policy is known to allow signing without PIN, the CLI skips the extra
VERIFYunless you explicitly supply a PIN source. - If the policy is unknown, the CLI keeps the conservative behavior and still requires
VERIFY.
Run expert diagnostics:
piv doctor --reader "YubiKey 5C NFC" --with-select
piv diag tlv decode --in response.bin
piv diag object read chuid --reader "YubiKey 5C NFC"Treat these commands as state-changing operations:
cert importcert deletekey generatekey deletemgm rotatesetup initsetup resetsetup reset-slot
Prefer --dry-run when available. Use --yes only when your automation already validated the target device and credentials.
Credential-bearing commands accept explicit stdin or environment-variable options. Prefer those mechanisms over shell arguments so that secrets do not leak into shell history or process listings.
APDU traces can contain credential material and token metadata. Route traces to a controlled destination with --trace-file, and redact them before sharing.