fix(yubikey): verify enrollment + FIPS PIN handling + work-checklist#295
Merged
Conversation
Two yk-enroll fixes from real macOS dogfooding:
1. Trust the filesystem, not exit codes.
When the user pressed Ctrl+C at the FIDO2 PIN prompt during
ssh-keygen enrollment, ssh-keygen returned a status that the
wrapping function reported as success in fish's pipeline. Result:
the wizard printed 'Enrolled: <path>' and 'Done. Next steps' even
though no key file was ever written. Now both the bash and fish
wizards stat <path> and <path>.pub after yk-ssh-new returns and
abort with a clear error if either is missing. The Done summary
block is also gated on the pubkey existing.
2. FIPS YubiKeys ship with factory PIN 123456.
ykman fido info reports 'PIN is set' on a brand-new YubiKey 5
FIPS, even though the PIN is the publicly documented default. The
wizard now detects FIPS via the device type and warns explicitly:
FIDO2 PIN is set — but this is a FIPS YubiKey, which ships with
factory default PIN '123456'. If you haven't changed it yourself,
rotate it now.
Re-run with --rotate-pin to change it now.
New --rotate-pin flag forces a change-pin call even when one is
already set, so users can rotate the factory default without
having to remember the raw ykman incantation.
Removed the half-baked interactive 'Change PIN now? [y/N]' prompt:
it deadlocked bats (stdin-is-a-tty) and added zero value over the
explicit --rotate-pin flag.
Tests: 16 bats cases (5 new): FIPS warning under --check, --rotate-pin
forces change, --rotate-pin under --check is a no-op, non-FIPS keys
are NOT prompted, and the Ctrl+C regression (ssh-keygen exits 0 but
no file written -> wizard aborts and never says 'Done').
Docs: docs/yubikey.md gained a 'FIPS YubiKeys ship with a factory
PIN' section and the post-condition guarantee in the step-5 bullet.
Some setup steps can't be automated by chezmoi: corporate URLs that require the work network/VPN, browser-based MFA enrollment, per-user sign-ins. Today these live in a wiki tab nobody remembers to open on a fresh machine. Add work-checklist (bash) and work_checklist (fish): a side-effect- free helper that prints the work-only manual checklist. Includes https://aka.ms/CloudMFA for corporate SSO MFA enrollment plus the usual gh ssh-key add / gh auth login / az login reminders. yk-enroll's Done. footer now points users at work-checklist so it's discovered organically right after YubiKey enrollment finishes. Tests: 3 bats cases (CloudMFA URL present, mentions yk-enroll, idempotent / no side effects). Docs: docs/yubikey.md gained an 'On work machines' section under 'Multiple YubiKeys' and a helpers-table entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #294.
What
Three related fixes/features from real macOS dogfooding with a fresh YubiKey 5C NFC FIPS:
1. Verify file post-condition (Ctrl+C regression)
When the user pressed Ctrl+C at
Enter PIN for authenticator:mid-ssh-keygen, the wrapping function returned a status that fish's pipeline reported as success. The wizard then printedEnrolled: <path>and theDone. Next stepsblock — even though no key file was written. Trust the filesystem, not exit codes.Now both bash and fish wizards
stat<out_path>and<out_path>.pubafteryk-ssh-newreturns and abort with a clearAborted: ... was not createdif either is missing. TheDone.summary is gated on the pubkey actually existing on disk.2. FIPS YubiKey factory PIN handling
Brand-new YubiKey 5 FIPS keys ship with PIN
123456.ykman fido inforeports "PIN is set" — true, but the PIN is publicly documented. The wizard now:--rotate-pinflag forcesykman fido access change-pineven when one is already set.The half-baked interactive
Change PIN now? [y/N]prompt from an earlier attempt was removed — it deadlocked bats and added zero value over the explicit flag.3.
work-checklistfor manual post-install stepsSome setup steps can't be automated by chezmoi: corporate URLs that require the work network/VPN (e.g.
https://aka.ms/CloudMFAfor SSO MFA enrollment), browser-based MFA enrollment, per-user sign-ins. Today these live in a wiki tab nobody remembers to open on a fresh machine.New
work-checklist(bash) /work_checklist(fish) is a side-effect-free helper that prints the work-only manual checklist:yk-enroll'sDone.footer now points users atwork-checklistso it's discovered organically right after YubiKey enrollment finishes — no hard-coded URL exposed unless the user asks.Verify
19 bats cases (8 new this PR):
warns about FIPS factory default PIN(under--check, no prompts)--rotate-pin forces change-pin even when PIN is set--rotate-pin under --check is a no-opnon-FIPS key with PIN set does NOT prompt for rotationaborts when ssh-keygen exits 0 but no file was written(Ctrl+C regression)work-checklist: prints CloudMFA URLwork-checklist: mentions yk-enrollwork-checklist: idempotent (no side effects, repeatable)Files
home/dot_config/shell/functions/yk-enroll.sh—--rotate-pin, FIPS warning, post-condition check, work-checklist hinthome/dot_config/fish/functions/yk_enroll.fish— samehome/dot_config/shell/functions/work-checklist.sh(new)home/dot_config/fish/functions/work_checklist.fish(new)tests/bash/yk-enroll.bats— 5 new teststests/bash/work-checklist.bats(new, 3 tests)docs/yubikey.md— FIPS factory PIN section, post-condition note,work-checklistsection + helpers-table entry