Skip to content

fix(doctor): SSH connectivity check ignores TERMINAL_SSH_USER / PORT / KEY#26851

Closed
Carry00 wants to merge 1 commit into
NousResearch:mainfrom
Carry00:fix/doctor-ssh-ignores-user-port-key
Closed

fix(doctor): SSH connectivity check ignores TERMINAL_SSH_USER / PORT / KEY#26851
Carry00 wants to merge 1 commit into
NousResearch:mainfrom
Carry00:fix/doctor-ssh-ignores-user-port-key

Conversation

@Carry00

@Carry00 Carry00 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Bug

When TERMINAL_ENV=ssh is set, hermes doctor tests SSH connectivity with:

ssh -o ConnectTimeout=5 -o BatchMode=yes <TERMINAL_SSH_HOST> echo ok

This ignores TERMINAL_SSH_USER, TERMINAL_SSH_PORT, and TERMINAL_SSH_KEY, so the check connects as the current OS user on port 22 with no specific identity file. If the remote requires a different user or key (the common case), the check always fails with Permission denied — even though the agent itself connects successfully.

Root cause

doctor.py line 1053 only reads TERMINAL_SSH_HOST and passes it directly to ssh, discarding the other three TERMINAL_SSH_* env vars that the terminal tool itself uses.

Fix

Build the ssh command using all four env vars — user@host, -p PORT, and -i KEY — to match the connection parameters the agent actually uses.

ssh_user = os.getenv("TERMINAL_SSH_USER")
ssh_port = os.getenv("TERMINAL_SSH_PORT")
ssh_key  = os.getenv("TERMINAL_SSH_KEY")
target   = f"{ssh_user}@{ssh_host}" if ssh_user else ssh_host
cmd      = ["ssh", "-o", "ConnectTimeout=5", "-o", "BatchMode=yes"]
if ssh_port: cmd += ["-p", ssh_port]
if ssh_key:  cmd += ["-i", os.path.expanduser(ssh_key)]
cmd += [target, "echo ok"]

Test

Before the fix — with TERMINAL_SSH_USER=carry configured:

✗ SSH connection to 10.8.0.5

After the fix:

✓ SSH connection to 10.8.0.5

🤖 Generated with Claude Code

…TERMINAL_SSH_KEY

The SSH connectivity check in `run_doctor` only passed the host to ssh,
using the current OS user and default port 22. When the target requires a
different user (TERMINAL_SSH_USER), non-standard port (TERMINAL_SSH_PORT),
or a specific identity file (TERMINAL_SSH_KEY), the check always failed
with "Permission denied" — even though the agent itself connects fine.

Fix: read all four TERMINAL_SSH_* env vars and build the ssh command with
-p, -i, and user@host as appropriate, matching how the terminal tool
actually establishes the connection.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard backend/ssh SSH remote execution labels May 16, 2026
teknium1 added a commit that referenced this pull request May 17, 2026
…tors

Adds release-note attribution mappings for the contributors from group 5:
- @haran2001 (PR #27070, #27068)
- @ms-alan (PR #26443)
- @godlin-gh (PR #26118)
- @wesleysimplicio (PR #25777, ext-email form)
- @Carry00 (PR #26851)
- @alaamohanad169-ship-it (PR #26036)
- @hawknewton (PR #26294)

(YanzhongSu PR #25879 and flamiinngo PR #27231 already mapped.)
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #27382 — your commit was cherry-picked onto current main as part of a batch salvage of low-risk new-contributor PRs. Authorship preserved (fix(doctor): SSH check ignores TERMINAL_SSH_USER, TERMINAL_SSH_PORT, TERMINAL_SSH_KEY). Thanks for the contribution.

@teknium1 teknium1 closed this May 17, 2026
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/ssh SSH remote execution comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants