You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ssh): the key prefix matches with a hyphen or an underscore in one place, and list, register, rotate and status never fall back to the keys of other projects #1920
devops ssh list shows managed SSH keys of other projects, and devops ssh register, rotate and status can pick a key of another project without a message. A person asked why list shows keys that do not carry the project prefix.
Evidence
In this repository the derived prefix is devops-cli (from get_ssh_key_prefix(): the folder or devcontainer name, with a hyphen). The managed key of the project is named devops_cli-id_ed25519-20260831 (with an underscore).
find_newest_key in src/devops_cli/crypto/ssh_keys.py retries with the other spelling (- and _ swapped), so status and register find the project key. list_keys in src/devops_cli/commands/ssh.py does not retry. It finds no key, and its fallback (if not keys and prefix is None: keys = list_managed_keys_info(target_key_dir)) lists every managed key. The output then holds the keys of two other projects.
Probe on 2026-10-22: list_managed_keys(dir, prefix="devops-cli") returns [], with "devops_cli" it returns the project key, and with no prefix it returns three keys.
find_newest_key also has fallback_to_any=True by default. If no key of the project exists, register, rotate and status use the newest key of any project. register would then upload a key of another project to the account under the project title, and rotate would rotate it.
Remedy
Define the prefix match in one place: list_managed_keys treats - and _ as the same character, and no caller adds its own retry. Remove the silent fallbacks to keys of other prefixes. Add devops ssh list --all for the case where a person wants every managed key. When no key of the project exists, register, rotate and status say so and point to devops ssh generate. Write the tests first, with a tmp_path key directory that holds keys of the project and of two other projects: list shows only the project keys, --all shows all, register and rotate never touch another project's key, and the hyphen and underscore spellings both match.
Cause devops ssh list found no key for the prefix devops-cli, because the key of the project is devops_cli-id_ed25519-20260831, with an underscore. It then listed the keys of all projects. find_newest_key also used the newest key of any project when no key of the prefix existed. So register could upload a key of another project to GitHub, and rotate could rotate it. register also compared the prefix a second time to build the key title. That comparison did not treat a hyphen and an underscore as the same character, so the project key got the title devops-cli-devops_cli-id_ed25519-20260831.
Change list_managed_keys is the one place that selects keys by prefix. It treats a hyphen and an underscore as the same character. find_newest_key has no retry and no fallback_to_any parameter. list has no fallback and has the new option --all. --all together with --prefix is a usage error, also in a dry run. register takes the key title from the key file when the key has a prefix. When no key of the prefix exists, register, rotate and status say so and point to devops ssh generate. The post-start lifecycle of the devcontainer keeps its order of keys: the workspace prefix, then the key with no prefix, then the newest unmanaged key. The change deletes the messages no_managed_keys, GeneralMessages.no_ssh_key_found and SSHErrorMessages.no_ssh_key_found, because nothing uses them. It also changes the text of no_managed_keys_pattern, because Rich…
Acceptance Criteria of docs/agent/tasks/task-1920-the-ssh-key-prefix-matches-in-one-place.md:
A prefix with a hyphen and a prefix with an underscore each match the keys of both spellings, and no key of another project (test_a_prefix_matches_the_keys_of_both_separator_spellings).
A prefix with no key finds no key and never the key of another project (test_a_prefix_with_no_key_finds_no_key_and_never_the_key_of_another_project). The empty prefix matches only the keys without a prefix (test_the_empty_prefix_matches_only_the_keys_without_a_prefix).
devops ssh list shows only the project key, and --all shows the keys of all three projects (test_list_shows_only_the_keys_of_the_project_prefix, test_list_with_all_shows_the_keys_of_every_project).
--all together with --prefix is a usage error, also in a dry run (test_list_refuses_all_together_with_a_prefix).
list --all of a directory with no managed key names both file name forms (test_list_with_all_of_a_directory_with_no_managed_key_names_the_expected_file_names).
list of a prefix with no key shows no key of another project. It names the prefix and points to devops ssh generate and to --all (test_list_of_a_project_with_no_key_names_the_prefix_and_never_shows_other_projects).
register sends the public key of the project key to both GitHub endpoints and no other key. It signs commits with the project key only (test_register_adds_the_key_of_the_project_to_github).
register titles a key with a prefix with its own file name. It gives the prefix of the project to a key with no prefix (test_register_titles_a_key_with_its_own_prefix_or_with_the_prefix_of_the_project).
With no key of the prefix, register sends no request, exits with code 1 and points to devops ssh generate (test_register_of_a_project_with_no_key_sends_nothing_and_points_to_generate).
rotate makes the new key with the prefix, reports the project key as the old key and leaves every key of another project (test_rotate_replaces_the_key_of_the_project_and_leaves_the_keys_of_other_projects). With no key of the prefix, it changes no file, sends no request and exits with code 0 (test_rotate_of_a_project_with_no_key_changes_nothing_and_points_to_generate).
status shows the project key. With no key of the prefix, it warns and exits with code 0 (test_status_shows_the_key_of_the_project, test_status_of_a_project_with_no_key_names_the_prefix_and_points_to_generate).
The post-start lifecycle signs with a key of the workspace prefix in either spelling (test_post_start_honors_workspace_ssh_key_prefix). With no such key, it signs with the managed key that has no prefix, then with the newest unmanaged key (test_post_start_signs_with_a_key_without_a_prefix_when_the_workspace_has_none). It never signs with a key of another project (test_post_start_does_not_adopt_foreign_prefixed_key).
The tests of register and rotate set GIT_CONFIG_GLOBAL to a file under tmp_path (global_git_config). They leave the global git config of the test worker unchanged, so a later test that runs git commit is not affected.
docs/CLI_REFERENCE.md, docs/commands/ssh.md and docs/MCP_TOOLS.md list the --all option. README.md and docs/ROUTINE_TASKS.md say that list shows the keys of the project prefix.
Cause devops ssh list found no key for the prefix devops-cli, because the key of the project is devops_cli-id_ed25519-20260831, with an underscore. It then listed the keys of all projects. find_newest_key also used the newest key of any project when no key of the prefix existed. So register could upload a key of another project to GitHub, and rotate could rotate it. register also compared the prefix a second time to build the key title. That comparison did not treat a hyphen and an underscore as the same character, so the project key got the title devops-cli-devops_cli-id_ed25519-20260831.
Change list_managed_keys is the one place that selects keys by prefix. It treats a hyphen and an underscore as the same character. find_newest_key has no retry and no fallback_to_any parameter. list has no fallback and has the new option --all. --all together with --prefix is a usage error, also in a dry run. register takes the key title from the key file when the key has a prefix. When no key of the prefix exists, register, rotate and status say so and point to devops ssh generate. The post-start lifecycle of the devcontainer keeps its order of keys: the workspace prefix, then the key with no prefix, then the newest unmanaged key. The change deletes the messages no_managed_keys, GeneralMessages.no_ssh_key_found and SSHErrorMessages.no_ssh_key_found, because nothing uses them. It also changes the text of no_managed_keys_pattern, because Rich…
Acceptance Criteria of docs/agent/tasks/task-1920-the-ssh-key-prefix-matches-in-one-place.md:
A prefix with a hyphen and a prefix with an underscore each match the keys of both spellings, and no key of another project (test_a_prefix_matches_the_keys_of_both_separator_spellings).
A prefix with no key finds no key and never the key of another project (test_a_prefix_with_no_key_finds_no_key_and_never_the_key_of_another_project). The empty prefix matches only the keys without a prefix (test_the_empty_prefix_matches_only_the_keys_without_a_prefix).
devops ssh list shows only the project key, and --all shows the keys of all three projects (test_list_shows_only_the_keys_of_the_project_prefix, test_list_with_all_shows_the_keys_of_every_project).
--all together with --prefix is a usage error, also in a dry run (test_list_refuses_all_together_with_a_prefix).
list --all of a directory with no managed key names both file name forms (test_list_with_all_of_a_directory_with_no_managed_key_names_the_expected_file_names).
list of a prefix with no key shows no key of another project. It names the prefix and points to devops ssh generate and to --all (test_list_of_a_project_with_no_key_names_the_prefix_and_never_shows_other_projects).
register sends the public key of the project key to both GitHub endpoints and no other key. It signs commits with the project key only (test_register_adds_the_key_of_the_project_to_github).
register titles a key with a prefix with its own file name. It gives the prefix of the project to a key with no prefix (test_register_titles_a_key_with_its_own_prefix_or_with_the_prefix_of_the_project).
With no key of the prefix, register sends no request, exits with code 1 and points to devops ssh generate (test_register_of_a_project_with_no_key_sends_nothing_and_points_to_generate).
rotate makes the new key with the prefix, reports the project key as the old key and leaves every key of another project (test_rotate_replaces_the_key_of_the_project_and_leaves_the_keys_of_other_projects). With no key of the prefix, it changes no file, sends no request and exits with code 0 (test_rotate_of_a_project_with_no_key_changes_nothing_and_points_to_generate).
status shows the project key. With no key of the prefix, it warns and exits with code 0 (test_status_shows_the_key_of_the_project, test_status_of_a_project_with_no_key_names_the_prefix_and_points_to_generate).
The post-start lifecycle signs with a key of the workspace prefix in either spelling (test_post_start_honors_workspace_ssh_key_prefix). With no such key, it signs with the managed key that has no prefix, then with the newest unmanaged key (test_post_start_signs_with_a_key_without_a_prefix_when_the_workspace_has_none). It never signs with a key of another project (test_post_start_does_not_adopt_foreign_prefixed_key).
The tests of register and rotate set GIT_CONFIG_GLOBAL to a file under tmp_path (global_git_config). They leave the global git config of the test worker unchanged, so a later test that runs git commit is not affected.
docs/CLI_REFERENCE.md, docs/commands/ssh.md and docs/MCP_TOOLS.md list the --all option. README.md and docs/ROUTINE_TASKS.md say that list shows the keys of the project prefix.
Activity
dan-petty commentedon Oct 22, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The candidate fixes incorrect behavior in SSH key handling.The issue allows commands to use keys from other projects without warning.Users can accidentally use or modify keys from other projects.Requires changes in key matching and command behavior with tests.fix(ssh): match a key prefix in one place and never use keys of other…
dan-petty commentedon Oct 22, 2026
What changed
#1927, merged into
release/v0.2.39as 5899947.15 file(s) changed.
How it was verified
Check runs at b4d68f5:
Acceptance Criteria of
docs/agent/tasks/task-1920-the-ssh-key-prefix-matches-in-one-place.md:test_a_prefix_matches_the_keys_of_both_separator_spellings).test_a_prefix_with_no_key_finds_no_key_and_never_the_key_of_another_project). The empty prefix matches only the keys without a prefix (test_the_empty_prefix_matches_only_the_keys_without_a_prefix).devops ssh listshows only the project key, and--allshows the keys of all three projects (test_list_shows_only_the_keys_of_the_project_prefix,test_list_with_all_shows_the_keys_of_every_project).--alltogether with--prefixis a usage error, also in a dry run (test_list_refuses_all_together_with_a_prefix).list --allof a directory with no managed key names both file name forms (test_list_with_all_of_a_directory_with_no_managed_key_names_the_expected_file_names).listof a prefix with no key shows no key of another project. It names the prefix and points todevops ssh generateand to--all(test_list_of_a_project_with_no_key_names_the_prefix_and_never_shows_other_projects).registersends the public key of the project key to both GitHub endpoints and no other key. It signs commits with the project key only (test_register_adds_the_key_of_the_project_to_github).registertitles a key with a prefix with its own file name. It gives the prefix of the project to a key with no prefix (test_register_titles_a_key_with_its_own_prefix_or_with_the_prefix_of_the_project).registersends no request, exits with code 1 and points todevops ssh generate(test_register_of_a_project_with_no_key_sends_nothing_and_points_to_generate).rotatemakes the new key with the prefix, reports the project key as the old key and leaves every key of another project (test_rotate_replaces_the_key_of_the_project_and_leaves_the_keys_of_other_projects). With no key of the prefix, it changes no file, sends no request and exits with code 0 (test_rotate_of_a_project_with_no_key_changes_nothing_and_points_to_generate).statusshows the project key. With no key of the prefix, it warns and exits with code 0 (test_status_shows_the_key_of_the_project,test_status_of_a_project_with_no_key_names_the_prefix_and_points_to_generate).test_post_start_honors_workspace_ssh_key_prefix). With no such key, it signs with the managed key that has no prefix, then with the newest unmanaged key (test_post_start_signs_with_a_key_without_a_prefix_when_the_workspace_has_none). It never signs with a key of another project (test_post_start_does_not_adopt_foreign_prefixed_key).registerandrotatesetGIT_CONFIG_GLOBALto a file undertmp_path(global_git_config). They leave the global git config of the test worker unchanged, so a later test that runsgit commitis not affected.docs/CLI_REFERENCE.md,docs/commands/ssh.mdanddocs/MCP_TOOLS.mdlist the--alloption.README.mdanddocs/ROUTINE_TASKS.mdsay thatlistshows the keys of the project prefix.dan-petty commentedon Oct 22, 2026
What changed
#1927, merged into
release/v0.2.39as 5899947.15 file(s) changed.
How it was verified
Check runs at b4d68f5:
Acceptance Criteria of
docs/agent/tasks/task-1920-the-ssh-key-prefix-matches-in-one-place.md:test_a_prefix_matches_the_keys_of_both_separator_spellings).test_a_prefix_with_no_key_finds_no_key_and_never_the_key_of_another_project). The empty prefix matches only the keys without a prefix (test_the_empty_prefix_matches_only_the_keys_without_a_prefix).devops ssh listshows only the project key, and--allshows the keys of all three projects (test_list_shows_only_the_keys_of_the_project_prefix,test_list_with_all_shows_the_keys_of_every_project).--alltogether with--prefixis a usage error, also in a dry run (test_list_refuses_all_together_with_a_prefix).list --allof a directory with no managed key names both file name forms (test_list_with_all_of_a_directory_with_no_managed_key_names_the_expected_file_names).listof a prefix with no key shows no key of another project. It names the prefix and points todevops ssh generateand to--all(test_list_of_a_project_with_no_key_names_the_prefix_and_never_shows_other_projects).registersends the public key of the project key to both GitHub endpoints and no other key. It signs commits with the project key only (test_register_adds_the_key_of_the_project_to_github).registertitles a key with a prefix with its own file name. It gives the prefix of the project to a key with no prefix (test_register_titles_a_key_with_its_own_prefix_or_with_the_prefix_of_the_project).registersends no request, exits with code 1 and points todevops ssh generate(test_register_of_a_project_with_no_key_sends_nothing_and_points_to_generate).rotatemakes the new key with the prefix, reports the project key as the old key and leaves every key of another project (test_rotate_replaces_the_key_of_the_project_and_leaves_the_keys_of_other_projects). With no key of the prefix, it changes no file, sends no request and exits with code 0 (test_rotate_of_a_project_with_no_key_changes_nothing_and_points_to_generate).statusshows the project key. With no key of the prefix, it warns and exits with code 0 (test_status_shows_the_key_of_the_project,test_status_of_a_project_with_no_key_names_the_prefix_and_points_to_generate).test_post_start_honors_workspace_ssh_key_prefix). With no such key, it signs with the managed key that has no prefix, then with the newest unmanaged key (test_post_start_signs_with_a_key_without_a_prefix_when_the_workspace_has_none). It never signs with a key of another project (test_post_start_does_not_adopt_foreign_prefixed_key).registerandrotatesetGIT_CONFIG_GLOBALto a file undertmp_path(global_git_config). They leave the global git config of the test worker unchanged, so a later test that runsgit commitis not affected.docs/CLI_REFERENCE.md,docs/commands/ssh.mdanddocs/MCP_TOOLS.mdlist the--alloption.README.mdanddocs/ROUTINE_TASKS.mdsay thatlistshows the keys of the project prefix.feat(release): v0.2.39 (#1947)