Skip to content

fix(tunnel): skip endpoint credential validation for direct tunnels#963

Closed
WardenPro wants to merge 5 commits into
Termix-SSH:dev-2.5.0from
WardenPro:fix/direct-tunnel-credential-validation
Closed

fix(tunnel): skip endpoint credential validation for direct tunnels#963
WardenPro wants to merge 5 commits into
Termix-SSH:dev-2.5.0from
WardenPro:fix/direct-tunnel-credential-validation

Conversation

@WardenPro

@WardenPro WardenPro commented Jun 26, 2026

Copy link
Copy Markdown

Problem

A user connecting to their server using SSH key authentication only (no password) sets up a LOCAL tunnel with "This host (direct tunnel)" as the endpoint.

When trying to start the tunnel, Termix throws this error:

Cannot connect tunnel '...': endpoint host requires password authentication but no plaintext password available.

The user never configured a password — the server doesn't have one. They use an SSH key stored in Termix's credential system. The SSH terminal works perfectly fine with that same host, but the tunnel fails every time.

Root Cause

When building the tunnel connect request, the frontend needs to fill the endpointAuthMethod field. For a direct tunnel ("This host"), there is no separate endpoint host to look up, so endpointSsh is undefined. The code falls back to a hardcoded default:

endpointAuthMethod: endpointSsh?.authType ?? "password"

This sends "password" to the backend even when the host uses SSH key auth. The backend sees authMethod: "password" with no password available and blocks the connection.

Fix

Two places corrected:

  1. Frontend — for a direct tunnel, the endpoint is the same host as the source, so use its actual authType instead of the "password" fallback.
  2. Backend — defensive guard: skip endpoint credential validation for direct (single-host) tunnels, which never open a second SSH connection.

Test plan

  • Host configured with SSH key auth (credential or direct key)
  • LOCAL tunnel with "This host (direct tunnel)" → connects without error
  • Tunnel to a separate SSH endpoint → credential validation still works correctly

LukeGus and others added 5 commits June 26, 2026 02:36
Single-host (direct) tunnels reuse the source SSH connection and don't
establish a separate endpoint connection, so validating endpoint
credentials is incorrect and blocks users with SSH key auth from
connecting via "This host (direct tunnel)".

Wraps both password and key credential checks in !isSingleHostTunnel()
so the validation only runs for multi-hop S2S tunnels that actually
need a second SSH connection.
When isDirect=true, endpointSsh is undefined so endpointSsh?.authType
falls back to the hardcoded "password" string. For direct tunnels the
endpoint IS the source host, so use sshHost.authType instead.

This fixes tunnels failing with "password authentication required" when
the host uses SSH key or credential-based authentication.
@LukeGus LukeGus changed the base branch from main to dev-2.5.0 June 28, 2026 07:04
@LukeGus

LukeGus commented Jun 28, 2026

Copy link
Copy Markdown
Member

LGTM, thanks

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.

2 participants