Repository navigation
Description
Problem Description
devops ssh rotate gives each rotated key GitHub access and makes it the git signing key, also for a key that is only for SSH to hosts. make ssh-rotate in dan-petty/homelab runs devops ssh rotate --prefix ansible. The key of that prefix is the Ansible key: devops infra gives it to Ansible to reach the nodes, and it has no other use.
After rotate (src/devops_cli/commands/ssh.py:235) makes the new key, it does these steps for each prefix:
register_key_on_github(src/devops_cli/github/ssh.py) adds the public key to the GitHub account as an authentication key and as a signing key._configure_git_signingcallsconfigure_git_signing(src/devops_cli/crypto/ssh_keys.py:327). It sets the key as the SSH commit signing key in the global git config, and in the local config of the working directory when that is a repository (the homelab clone).- It says that the old key stays on GitHub for the grace days, and that a person removes it by hand.
Effects for a key that is only for the nodes:
- Each place that holds the Ansible key then holds a GitHub credential with the access of the account.
- The commits of the person are signed with the node key in each repository that has no local signing key.
- The GitHub account gets one more authentication key and one more signing key at each rotation.
The current key of the prefix is from 2026-09-09. With ssh.rotation_days 90, its first rotation is due on 2026-12-08.
Reproduction Steps
- Read
rotateinsrc/devops_cli/commands/ssh.py. - In the homelab clone, run
devops ssh rotate --prefix ansible --dry-run(2026-11-18). The plan lists these requests for the node key:
1. POST /user/keys {"title": "ansible-20261118", "key": "<public key>"}
3. POST /user/ssh_signing_keys {"title": "ansible-20261118", "key": "<public key>"}
5. git config --global gpg.format ssh
6. git config --global user.signingkey <path>
7. git config --global commit.gpgsign true
8-10. the same three keys with git -C <homelab clone> config --local
Expected vs Actual Behavior
Expected: the rotation of a key that is only for hosts makes the new key and tells the person to put the public key on the hosts. It makes no GitHub request and no change of the git config.
Actual: the rotation registers the node key on GitHub for authentication and signing, and points the git commit signing at it.
Proposed Fix
Let each key prefix state its uses. For example, rotate registers on GitHub and sets the signing only for the project prefix (ssh.key_prefix), or a setting names the prefixes that are only for hosts. The homelab role ansible/roles/common/tasks/user.yaml already puts a key on the hosts with authorized_key.
Acceptance Criteria
- A test:
rotateof a prefix that is only for hosts makes no GitHub request and does not change the git config. It fails onmain(devops ci fail-to-pass). - A test:
rotateof the project prefix still registers the key and sets the signing. - The dry run of a prefix that is only for hosts lists no GitHub request.
- The help and the reference of
devops ssh rotatetell which prefixes go to GitHub.
Alternatives check of 2026-11-19: none.
Tool: none found.
Reason: Four searches found no open tool; the results were unrelated reference pages, and the need is a conditional inside the project's own rotate command and plan builder, which no external tool supplies.
Lacks:
- No tool tells a host-only prefix from the project prefix
- No tool gates GitHub key registration and signing by prefix
- No tool edits the dry-run plan to drop GitHub requests
Proposed design
Problem statement
Apply GitHub registration and git signing only to the project prefix in devops ssh rotate. The command registers every rotated key on GitHub and sets it as the git signing key. It does this also for a key that only reaches hosts. The Ansible key then becomes a GitHub credential and signs commits. A host-only rotation prints the public key and tells the person to put it on the hosts.
Acceptance criteria
Requirement: Host-only prefix skips GitHub
devops ssh rotate SHALL make no GitHub key registration request for a prefix that is not the project prefix.
Scenario: Rotate the Ansible prefix
- WHEN A test calls
rotatewith--prefix ansibleand the project prefixproject. The test uses a temporary HOME and a temporary git repository, and it patchesregister_key_on_githubinsrc/devops_cli/github/ssh.py. - THEN The test asserts that
register_key_on_githubwas not called and that the new key file exists in theansibleprefix directory.
Requirement: Host-only prefix keeps git config
devops ssh rotate SHALL leave the global and local git config unchanged for a prefix that is not the project prefix.
Scenario: No signing change for the Ansible prefix
- WHEN A test calls
rotatewith--prefix ansibleand the project prefixproject. The test uses a temporary HOME and a temporary git repository, and it patchesregister_key_on_github. - THEN The test asserts that
git config --globalandgit -C <repo> config --localshow nouser.signingkey, nogpg.formatand nocommit.gpgsignvalue.
Requirement: Host-only rotation prints the host instruction
devops ssh rotate MUST print the new public key and an instruction to put it on the hosts for a host-only prefix.
Scenario: Read the host-only rotation output
- WHEN A test calls
rotatewith--prefix ansibleand the project prefixproject. The test uses a temporary HOME, and it patchesregister_key_on_github. - THEN The test asserts that the output holds the new public key and a line that tells the person to put the public key on the hosts. The test also asserts that the output holds no GitHub removal message.
Requirement: Project prefix still registers and signs
devops ssh rotate MUST register the new key on GitHub and set it as the git signing key for the project prefix.
Scenario: Rotate the project prefix
- WHEN A test calls
rotatewith--prefix projectand patchesregister_key_on_githubandconfigure_git_signing. - THEN The test asserts that
register_key_on_githubreceived the new public key and title, and thatconfigure_git_signingreceived the new key path.
Requirement: Host-only dry run lists no GitHub request
The dry run of devops ssh rotate SHALL list no GitHub key request and no git config command for a host-only prefix.
Scenario: Plan the Ansible rotation
- WHEN A test calls
plan_rotateinsrc/devops_cli/github/ssh_plans.pywithgithub_enabled=Falsefor the new key. - THEN The test asserts that the plan holds no
POST /user/keys, noPOST /user/ssh_signing_keysand noGETrequest to either key endpoint. The plan also holds nogit configline.
Requirement: The rotate help names the GitHub prefix
The help of devops ssh rotate MUST state that only the prefix in ssh.key_prefix registers on GitHub.
Scenario: Read the rotate help
- WHEN A test invokes
devops ssh rotate --helpand reads the output. - THEN The test asserts that the help names
ssh.key_prefixas the only prefix that registers on GitHub. The help says that every other prefix is for hosts only.
Requirement: The generated CLI reference holds the new help
The generated CLI reference MUST hold the new rotate help text after the change.
Scenario: Regenerate the CLI reference
- WHEN A test runs
uv run devops docs generateon the changed tree. - THEN
git status --porcelainprints no path, so the generated reference holds the new help text.
Existing Tool Considered
The alternatives check in the issue body records the verdict none and no tool. Four searches found no open, maintained tool or library that covers this need. The block lists what no tool supplies. The change edits src/devops_cli/commands/ssh.py, src/devops_cli/github/ssh_plans.py, src/devops_cli/github/ssh.py and their tests. Written cost: about 30,000 tokens to build and test. It is about 5,000 tokens for each later change to keep, and less than one day of elapsed time.
Key questions
- Which prefixes register on GitHub and use the new key for git signing?: Only the prefix that equals the configured project prefix,
ssh.key_prefix. Every other prefix is host-only: it skipsregister_key_on_githubandconfigure_git_signing. This fails closed: a typo in--prefixmakes a host-only key, never a GitHub credential. (best practice) [sources: src/devops_cli/commands/ssh.py:235, src/devops_cli/github/ssh.py, src/devops_cli/crypto/ssh_keys.py:327]- Chosen: Compare the active prefix with
ssh.key_prefix. It uses the prefix that the command already resolves, so no second list can disagree. - Rejected: Add a list of host-only prefixes. A new prefix stays a GitHub key by default, so the defect remains.
- Rejected: Add a
--githubor--no-githubflag. A person must remember the flag on each run, andmake ssh-rotatekeeps the defect. - Rejected: Add a per-prefix use map to the config. It adds a schema and a migration for one distinction that the project prefix already makes.
- Chosen: Compare the active prefix with
- Where does the shared prefix rule live?: In
src/devops_cli/github/ssh.pyas a pure functionregisters_on_github(prefix, project_prefix).commands/ssh.pyandgithub/ssh_plans.pyimport it. This avoids the import cycle that a helper incommands/ssh.pywould create, becausessh_plans.pyis imported by the command module. (best practice) [sources: src/devops_cli/github/ssh.py, src/devops_cli/github/ssh_plans.py, src/devops_cli/commands/ssh.py]- Chosen: Helper in
github/ssh.py. The plan builder already imports this module, so no cycle and one rule. - Rejected: Helper in
commands/ssh.py.ssh_plans.pywould import the command module and make a cycle. - Rejected: Copy the check at each call site. The copies drift, and one copy can skip the check.
- Chosen: Helper in
- What does a host-only rotation do after it makes the key?: It prints the new public key and one line that tells the person to put it on the hosts with the Ansible role. It makes no GitHub request and no git config change. It does not run
devops infra apply, because that path needs a saved plan and an agent access level abovenone. (best practice) [sources: src/devops_cli/commands/ssh.py:235, src/devops_cli/github/ssh_plans.py, CONTEXT.md]- Chosen: Print the public key and a host instruction. It meets the expected behavior and needs no host access and no new scope.
- Rejected: Write the key into the infra repo for Ansible. It couples the SSH command to one infra repo and needs a commit and a review for a key.
- Rejected: Run
devops infra applyto push the key. It couples key rotation to an infra plan and apply, which needs a saved plan and an access level.
- How does the dry run learn that a prefix is host-only?: The command computes the decision with
registers_on_githuband passesgithub_enabled=Falsetoplan_rotate. The plan builder then omits the two key requests and thegit configcommands. The plan builder does not read--prefixitself. (best practice) [sources: src/devops_cli/github/ssh_plans.py, src/devops_cli/commands/ssh.py:235, src/devops_cli/github/ssh.py]- Chosen: Pass a
github_enabledflag toplan_rotate. The live run and the dry run use one decision, and the plan builder stays a pure request builder. - Rejected: Let
plan_rotateread the prefix and config. It adds config and command concerns to the plan builder and can disagree with the live run. - Rejected: Build the plan in the command and skip
ssh_plans. The dry run and the live run then have two request lists.
- Chosen: Pass a
- Which prefixes show the GitHub removal message for the old key?: Only the project prefix. A host-only rotation says that the old key stays on the hosts until the person replaces it, and it says nothing about GitHub. (best practice) [sources: src/devops_cli/commands/ssh.py:235, src/devops_cli/github/ssh.py]
- Chosen: Show the removal message only for the project prefix. The old host key is not on GitHub, so a removal line for it is false.
- Rejected: Show it for every prefix. It tells the person to remove a key that GitHub never held.
- How do the tests prove the change with no network?: Patch
register_key_on_githubinsrc/devops_cli/github/ssh.py. Use a temporary HOME and a temporary git repository, and assert that the global and localuser.signingkeyvalues stay empty for the Ansible prefix. Patchregister_key_on_githubandconfigure_git_signingto assert the calls for the project prefix. Callplan_rotatewithgithub_enabled=Falsefor the dry run. (best practice) [sources: tests/crypto/test_ssh.py, src/devops_cli/github/ssh_plans.py, src/devops_cli/commands/ssh.py]- Chosen: Patch the two state-changing callers and inspect a temporary git config. The test needs no network, no GitHub account and no real user config.
- Rejected: Use a real GitHub session. It needs a token and a live account, and it changes the account at each run.
- Rejected: Read only the source code with no command run. It does not show that the command leaves the git config unchanged.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 18, 2026
A live high security issue: host-only keys gain GitHub authentication and signing access at every rotation, expanding the credential surface.Both concern SSH signing key configuration, but #66 isolates signing keys across devcontainers while the candidate stops rotate from registering host-only keys on GitHub.devops-cli-service commentedon Nov 19, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (4)
Searches run:
Sources:
devops-cli-service commentedon Nov 19, 2026
Status set to Ready at 5e6822d (see proposed design in issue body).
11 remaining items
fix(security): Add the rule that decides GitHub registration by prefix (
wip: 1 of 2 tasks of group 2, Gate the rotation and the dry run by th…
fix(security): Add the rule that decides GitHub registration by prefix (
fix(security): Gate the rotation and the dry run by the project prefix (
fix(security): Regenerate the ssh command page and the CLI reference (#…
docs(openspec): archive the change (#6339)
devops-cli-service commentedon Nov 19, 2026
Pull request #6473 is ready for review. The checks passed.
Spend: 99 model requests, 7371137 input tokens, 35243 output tokens.
devops-cli-service commentedon Nov 20, 2026
Released in v0.182.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.182.0
devops-cli-service commentedon Nov 20, 2026
Live since 2026-11-20 00:02 UTC