fix(devtools-proxy-support): support SSH password auth via keyboard-interactive COMPASS-10929 - #851
Open
TemaSM wants to merge 1 commit into
Open
Conversation
keyboard-interactivekeyboard-interactive COMPASS-10929
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #839
Description
MongoDB Compass's SSH
Passwordmode passes the configured password tossh2, but does not opt in tokeyboard-interactiveauthentication.This makes SSH tunnels fail when an OpenSSH/PAM server accepts that password only through
keyboard-interactive.The SSH agent now enables
tryKeyboardwhen a password is configured and uses it for one hidden, single-prompt challenge.Empty rounds do not consume the attempt, while visible prompts, multiple prompts, and later rounds receive empty responses so the stored password is not reused for OTP or MFA prompts.
A per-connection authentication selector preserves the existing
none → password → publickey → keyboard-interactiveorder.Once the server reports
partialSuccess, the keyboard-interactive password fallback is skipped for that connection, while other configured methods such aspublickeyremain available.A reconnect starts with fresh authentication state.
This does not change the public API, connection options, or dependencies.
Root cause
SSHAgentpassedpasswordtossh2.Client.connect(), but did not enabletryKeyboardor register thekeyboard-interactiveevent handler required byssh2.Servers advertising
publickey,keyboard-interactivetherefore exhausted the configured authentication methods before Compass attempted to connect to MongoDB, showing user popup with text:All configured authentication methods failed.The initial password fallback also needed to account for
partialSuccess.The default
ssh2method selector does not use that flag, so a server could acceptpasswordorpublickeyas one factor and then receive the configured password in its first hidden OTP prompt.Changes
tryKeyboardonly when the SSH URL contains a password.none → password → publickey → keyboard-interactive.partialSuccesscumulatively and skip the keyboard-interactive password fallback after any method succeeds partially.publickey, available after a partial success.methodsLeftwithout using it to reorder methods in this change.ssh2.Serverfixture and add unit and integration coverage for password, public-key, partial-success, prompt-shape, rejection, and reconnection paths.Security boundary
This is a password compatibility fallback, not a general interactive or MFA implementation.
Before any authentication method succeeds, the configured password is eligible only for the first non-empty round containing one hidden prompt.
After
ssh2reportspartialSuccess, keyboard-interactive is skipped for the rest of that SSH connection.A later failed method cannot clear that state, while a new connection receives a fresh selector.
Testing & validation
partialSuccesshandling.ssh2.Serverfixture to cover password, public-key, keyboard-interactive, and multi-step authentication.Tested with Node.js 22.23.1 and npm 11.17.0:
npm run test --workspace=@mongodb-js/devtools-proxy-support -- src/ssh-auth.spec.ts src/ssh.spec.ts: 38 passingnpm run compile --workspace=@mongodb-js/devtools-proxy-support: passingnpm run check --workspace=@mongodb-js/devtools-proxy-support: passingnpm run test-ci --workspace=@mongodb-js/devtools-proxy-support: 85 passing, 3 pending, 0 failingThe basic
keyboard-interactivepassword path was also tested manually with a locally patched Compass 1.49.12 build against a server advertisingpublickey,keyboard-interactive.The
partialSuccessboundary is covered by the automated SSH server fixture.Open Questions
None.
Checklist
- [ ] Documentation is changed or added