Repository navigation
Backlog
Description
Question
Should setup-github --configure drop the managed-key evidence probe and rely on GitHub's own refusal to stop a gh registration for a key that belongs to another account?
Background
#4482 registers the managed key through gh ssh-key add where gh is logged in with the key scopes, per the 2026-11-01 answer on #2552. Before any write, its gate runs an isolated, verbose, batch-mode ssh probe of the managed key (probe_managed_key / Test-ManagedKeyDenied). It lets the registration run only where that probe names gh's account, or shows the key offered and refused with no "Server accepts key" line.
The probe is redundant with what already stops a wrong-account write:
- The authentication add runs first, and the signing add follows only an authentication add that succeeded or that gh already listed.
- GitHub refuses an authentication key already in use on another account, so a key on another account never reaches the signing add.
What the probe adds is a warning naming the other account before any write. What it costs:
- A host that reaches GitHub only through its ssh config fails the isolated probe and is sent to the paste where gh would have registered the key correctly.
- The case-by-case reconciliation between gh's own lists and the ssh probes. That reconciliation produced a long tail of cross-state findings across 19 local review passes on Register the Managed SSH Key Through a Logged-In gh in setup-github #4482: a refused gate losing gh's listed state, the final checks contradicting gh's answer, and an unreachable GitHub read as an unregistered key.
Options
- Recommended: simplify. Drop the evidence probe and rely on GitHub's refusal. It removes the probe, its fingerprint and accept-line parsing, the Windows
Out-String -Width 500dependency, and most of the gh/ssh reconciliation it forces. It also lets an ssh-config-only host register through gh. The host-identity refusal that Decision: gh active account versus the host's ssh identity before setup-github registers a key #4483 decided stays as it is. What is lost is the pre-write warning naming the account a key already belongs to. GitHub's refusal still stops the add, and the script's warning still names the in-use cause. - Keep the probe as it is. It keeps a local guard that does not depend on GitHub's refusal, and the pre-write warning. The cost is the reconciliation code and its continuing edge cases, plus the ssh-config-only host ending at the paste.
What each option does to the work
- Option 1 is a follow-up pull request on
host-setup/linux/setup-github.sh,host-setup/windows/setup-github.ps1,tests/test_setup_github.pyand the two host-setup READMEs, after Register the Managed SSH Key Through a Logged-In gh in setup-github #4482 merges. - Option 2 needs no change.
Related
- Register the Managed SSH Key Through a Logged-In gh in setup-github #4482, which this decision does not hold.
- GitHub Key Registration Can Be Automated Through an Authenticated gh, Contrary to setup-github.sh #2552, which stays open for the maintainer's verification on a fresh host.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Register the Managed SSH Key Through a Logged-In gh in setup-github (#…
ptr727 commentedon Nov 28, 2026
Answered by the maintainer, 2026-11-27: option 1, simplify. Drop setup-github's managed-key evidence probe and rely on GitHub's own refusal of a key already in use on another account, replacing the case-by-case gh/ssh reconciliation. Land it before #2553 and #2557, which touch the same scripts. This issue is now ordinary backlog work.
ptr727 commentedon Nov 29, 2026
Two findings from CodeRabbit's review of promotion #4542 are folded in here by the maintainer's decision, since this simplification rewrites the same three files:
host-setup/windows/setup-github.ps1around line 822, andsetup-github.shreport_authenticationaround line 948. With noghlogin, a host that reaches GitHub only through its ssh config fails the isolated probe. It is then told to paste the key, and told that the key is "registered nowhere", even when the key is on the account. Fix: check the public authentication list first, withTest-KeyRegistered -Kind 'auth'orgithub_auth_key_registered. Onregistered, print an info line with no paste. Onmissing, keep the paste. Onunknown, warn that the registration could not be read, with no "registered nowhere" claim.tests/test_setup_github.py, around lines 1004 and 1591-1593. Both run only the registration and never the final reports. They search for a lowercase "paste" while the instruction reads "3. Paste the key below", and the Linux test reads stderr whileregistration_neededprints to stdout. Fix: run the reports, assert that neitherSet the key type to "Authentication key"norSet the key type to "Signing key"appears, and see each test fail against a deliberately broken report first.Promote Develop to Main: setup-github gh Key Add and .NET Packing (#4542