Skip to content

[PM-41898] SSH Agent v2: add per-key destination filtering - #22384

Open
V1rg1lee wants to merge 3 commits into
bitwarden:mainfrom
V1rg1lee:feature/ssh-agent-destination-filtering
Open

[PM-41898] SSH Agent v2: add per-key destination filtering#22384
V1rg1lee wants to merge 3 commits into
bitwarden:mainfrom
V1rg1lee:feature/ssh-agent-destination-filtering

Conversation

@V1rg1lee

Copy link
Copy Markdown

🎟️ Tracking

Related to #13401

GitHub Discussion: https://github.com/orgs/bitwarden/discussions/22382

Community feature request:
https://community.bitwarden.com/t/ssh-agent-allow-specifying-limiting-private-key-offers/79954

📔 Objective

The SSH agent can expose enough identities for an SSH server to hit MaxAuthTries before OpenSSH reaches the correct key.

This PR adds optional per-key destination filtering to SSH Agent v2 using the verified host-key fingerprint already provided by OpenSSH through session-bind@openssh.com.

SSH key items on Desktop can now be associated with one or more SHA256 host-key fingerprints. These settings are stored locally on Desktop and are not added to synchronized cipher data.

When a verified destination is available, the agent returns identities in this order:

  1. keys explicitly configured for the destination;
  2. unrestricted keys with no destinations configured.

Keys restricted to other destinations are omitted. Ordering within each group remains stable.

If no verified session binding is available, all identities are returned as before.

This allows a user to configure only the key they expect to use for a server and have it prioritized ahead of unrestricted Bitwarden identities, without requiring every other key to be configured first.

The destination setting is an identity-offering optimization, not an authorization boundary. This PR does not add hostname/IP matching, host-key discovery, ssh-keyscan, or changes to signing authorization.

🧪 Testing

Automated testing includes:

  • Rust unit and integration coverage for destination matching, filtering, prioritization, stable ordering, serialization, and the no-session-bind fallback.
  • Desktop/UI tests for local persistence, Save/Cancel behavior, validation, new-cipher persistence, and removal of destination restrictions.
  • cargo fmt --check
  • cargo check -p desktop_napi
  • node scripts/lint-rust.mjs --only clippy
  • Relevant Jest and TypeScript checks
  • ESLint and Prettier checks

Manual end-to-end testing was performed against a real OpenSSH server on Windows.

Before this change:

  • the Bitwarden agent returned 6 identities;
  • the correct key was reached too late;
  • the server disconnected with Too many authentication failures.

After configuring only the correct key for the destination and leaving the other keys unrestricted:

  • OpenSSH successfully bound the agent connection to the server host key;
  • the destination-matched Bitwarden identity was prioritized ahead of unrestricted Bitwarden identities;
  • the server accepted the correct RSA key and public-key authentication succeeded.

I also tested the stricter case where unrelated keys were restricted to other destinations. In that case, the agent returned only the matching identity.

📸 Screenshots

Configured destination

image

Validation

image

@V1rg1lee
V1rg1lee requested review from a team as code owners August 12, 2026 19:34
@bitwarden-bot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-41898
Link: https://bitwarden.atlassian.net/browse/PM-41898

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title SSH Agent v2: add per-key destination filtering [PM-41898] SSH Agent v2: add per-key destination filtering Aug 12, 2026
@bitwarden-bot bitwarden-bot added community-pr needs-qa Marks a PR as requiring QA approval labels Aug 12, 2026
@V1rg1lee
V1rg1lee force-pushed the feature/ssh-agent-destination-filtering branch from 854749a to 7b8acfc Compare August 12, 2026 22:26

@djsmith85 djsmith85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @V1rg1lee! The Desktop-Native product team will evaluate your contribution and discuss with the engineering team

Platform-owned changes are limited to the updated napi-file. @bitwarden/team-desktop-native-dev can re-request a review once they are happy with the proposed solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-pr needs-qa Marks a PR as requiring QA approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants