Mobile icon indicating copy to clipboard operation
Mobile copied to clipboard

Local connections use the credential's username instead of the host's (server does the opposite)

Open tydude001 opened this issue 3 weeks ago • 1 comments

What happened?

I have a key credential with a username (userA), used by a host whose own Username is userB. Connecting directly from the phone (no server linked), the server refused the key, because the app logged in as userA. After I cleared the credential's username, the host connected as userB.

The local resolver lets the credential's username win unless overrideCredentialUsername is set (src/core/transport/local/resolve.ts:128, same on main at 845d106 and dev-2.1.0 at f51e93b):

if (!src.overrideCredentialUsername && cred.username) {
  username = cred.username;
}

The server does the opposite. pickResolvedUsername in Termix-SSH/Termix src/backend/hosts/credential-username.ts says "An explicitly-set host username always wins … The credential's username is only used as a fallback when the host has none", and it has said that in every release since 2.5.1. The mobile host editor has no control for overrideCredentialUsername, so on the phone the host's Username field gets ignored with no warning.

Is credential-wins intended?

tests/core/transport/local/resolve.test.ts ("a linked login fills secrets, certificate and username") asserts the current behavior: host root plus credential deploy gives deploy. So it may be deliberate. If the mobile app should follow the server's rule, I'm happy to send a PR that uses the same precedence in resolveLogin, updates that assertion, and adds a test for the fallback. I didn't want to change an existing test without asking first.

Steps to reproduce

  1. Hosts → ⋮ → Credentials → + → Username userA, Sign in with SSH key, Make a new key.
  2. Authorize the public key for userB on a server (not for userA).
  3. Add a host with Username userB, using that credential, Connect from: this phone.
  4. Connect → "The login was refused".
  5. Clear the credential's Username → connect → it works as userB.

What did you expect?

The same rule as the server: the host's username when it's set, and the credential's only as a fallback.

App version

The App Store build current on 2026-11-07

Platform

iOS

Termix server version

None. No server linked; connecting from the phone.

Logs

Authentication failed: FunctionCallException: Calling the 'connect' function has failed (at ExpoModulesCore/ConcurrentFunctionDefinition.swift:88)
→ Caused by: SshCodedException: key refused, server allows publickey (at TermixSsh/TermixSshModule.swift:12)

Before you submit

  • [x] I searched open and closed issues and this is not a duplicate
  • [x] I am on the latest version, or I said which version I am on

tydude001 avatar Nov 07 '26 16:11 tydude001

Auto-triage

Local connections on the mobile app incorrectly prioritize the credential's username over the host's username, unlike the server behavior.

Field Value
Type Bug
Difficulty 2/5 (Small)
Priority Medium

A maintainer will take a look. If anything above looks wrong, just say so.

termix-triage-bot[bot] avatar Nov 07 '26 16:11 termix-triage-bot[bot]