Skip to content

fix: propagate SSH authentication errors to the UI#1169

Closed
eduardomozart wants to merge 9 commits intognmyt:mainfrom
eduardomozart:patch-4
Closed

fix: propagate SSH authentication errors to the UI#1169
eduardomozart wants to merge 9 commits intognmyt:mainfrom
eduardomozart:patch-4

Conversation

@eduardomozart
Copy link
Copy Markdown
Contributor

@eduardomozart eduardomozart commented Feb 24, 2026

📋 Description

This PR fixes an issue where users receive no visual feedback when an SSH connection fails due to authentication issues. While the backend correctly logs the failure, the error was not being properly bubbled up or handled by the frontend, resulting in a silent failure state.

When the ssh2 library emits an authentication failure, the error is caught in controllers/serverSession.js, but the response is either not sent or is sent in a format the UI doesn't recognize as a displayable error.

[0] 2026-02-24 10:43:21 [error] [controllers/serverSession.js:92] Failed to create connection for session sessionId=e7d6f9af-5bad-4071-a8c6-9a14feb154ae error=Invalid username stack=Error: Invalid username
[0]     at Client.connect (/home/vaultwarden/git/Nexterm/node_modules/ssh2/lib/client.js:203:13)
[0]     at createSSHClient (/home/vaultwarden/git/Nexterm/server/lib/ConnectionService.js:124:9)
[0]     at createSSHConnectionForSession (/home/vaultwarden/git/Nexterm/server/lib/ConnectionService.js:58:23)
[0]     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Fix

  • Updated server/controllers/serverSession.js to ensure that when a connection failure occurs, a proper error response (e.g., 500 or 401) is returned with a descriptive message.
  • Updated the frontend connection handler to catch this specific error and trigger a notification toast/alert.

How To Test

  • Attempt to open an SSH connection using invalid credentials (wrong password or incorrect private key).
  • Before fix: Errors only appear in server logs.
  • After fix: The UI should immediately display an error message such as: "SSH Connection Failed: All configured authentication methods failed."

2026-02-2411-54-07-ezgif com-video-to-gif-converter

🚀 Changes made to ...

  • 🔧 Server
  • 🖥️ Client
  • 📚 Documentation
  • 🔄 Other: ___

✅ Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have looked for similar pull requests in the repository and found none
  • This pull request does not contain translations (translations are managed through Crowdin)

🔗 Related Issues

Closes #1168

@eduardomozart eduardomozart marked this pull request as draft February 24, 2026 13:48
Eduardo Oliveira added 8 commits February 24, 2026 10:58
Replace the dedicated SESSION_ERROR state channel with the existing CONNECTIONS stream. server/controllers/serverSession.js now broadcasts connection failures on CONNECTIONS (including a sessionError object with sessionId and message). client/src/common/hooks/useStateStream.js removes STATE_TYPES.SESSION_ERROR. client/src/common/contexts/SessionContext.jsx now listens to STATE_TYPES.CONNECTIONS, looks for data.sessionError, shows the error toast, and cleans up active sessions/activeSessionId using the sessionId from that payload. This simplifies state channels and centralizes connection-related updates.
Server: await createConnectionForSession before broadcasting the new session; on failure remove the session and return a 400-style error payload instead of broadcasting a CONNECTIONS error message. This ensures the frontend only sees sessions that successfully connected.

Client: remove the StateStream CONNECTIONS error handler and related toast logic from SessionContext, since connection failures are now reported via the API response and handled by the API client/UI. Reduces transient/falsy UI state and centralizes error reporting.
@sonarqubecloud
Copy link
Copy Markdown

@eduardomozart eduardomozart marked this pull request as ready for review February 24, 2026 14:56
@tcatlas
Copy link
Copy Markdown
Collaborator

tcatlas commented Feb 25, 2026

May be a duplicate of #1053, which covers all connections not just SSH.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SSH Connection Fails Silently on Authentication Error

2 participants