Skip to content

Decision: drop setup-github's managed-key evidence probe and rely on GitHub's own refusal #4527

Backlog

Description

@ptr727

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

  1. 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 500 dependency, 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.
  2. 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

Related

Activity

  1. added
    decision
    on Nov 27, 2026
  2. ptr727 commented on Nov 28, 2026

    @ptr727
    OwnerAuthor

    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.

  3. removed
    decision
    on Nov 28, 2026
  4. ptr727 commented on Nov 29, 2026

    @ptr727
    OwnerAuthor

    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:

    1. The other-key branch asks for a paste without checking registration. This is host-setup/windows/setup-github.ps1 around line 822, and setup-github.sh report_authentication around line 948. With no gh login, 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, with Test-KeyRegistered -Kind 'auth' or github_auth_key_registered. On registered, print an info line with no paste. On missing, keep the paste. On unknown, warn that the registration could not be read, with no "registered nowhere" claim.
    2. The "configured host is not told to paste" tests check nothing. These are in 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 while registration_needed prints to stdout. Fix: run the reports, assert that neither Set the key type to "Authentication key" nor Set the key type to "Signing key" appears, and see each test fail against a deliberately broken report first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions