Skip to content

HOMELAB_PI_KEY_PATH with ~ (as documented) never loads the key #85

Closed

Description

@TMHSDigital

Summary

The documented HOMELAB_PI_KEY_PATH=~/.ssh/id_ed25519 never loads, because ~ is not expanded before readFileSync. Anyone who copies the README config gets every tool failing with ENOENT.

Where

  • mcp-server/src/utils/ssh-api.ts:170 (execSSH, privateKey: keyPath ? readFileSync(keyPath) : undefined)
  • mcp-server/src/utils/ssh-api.ts:42, :58 (key path read from env / HOMELAB_NODES as-is)
  • Docs that use ~: README.md:151, mcp-server/README.md:76,112, .env.example:4, docs/index.html / site.json
  • .github/workflows/e2e.yml (HOMELAB_PI_KEY_PATH: ~/.ssh/pi_key, a literal string in env:)

Details

MCP clients pass env values literally (no shell), and GitHub Actions env: values are literal too. Node does not expand ~, so readFileSync('~/.ssh/id_ed25519') throws ENOENT. Nothing in mcp-server/src uses os.homedir().

The throw also happens inside the Promise executor after the 30s timer is armed (ssh-api.ts:111-115), so the timer is never cleared and the error surfaces as a raw ENOENT instead of an SSHAuthError with a suggestion.

Impact

First-run failure for anyone following the README. The weekly live-Pi e2e workflow also cannot load its key.

Steps to reproduce

  1. Set HOMELAB_PI_KEY_PATH to ~/.ssh/id_ed25519 exactly as in README.md:151.
  2. Call homelab_sshTest.
  3. Result: ENOENT: no such file or directory, open '~/.ssh/id_ed25519'.

Suggested fix

  • Expand a leading ~ (~/ or ~\) with os.homedir() and path.resolve for both the default config and HOMELAB_NODES entries.
  • Read the key before creating the timer/Promise, and wrap read failures in an SSHAuthError that names the path.
  • In e2e.yml, use an absolute path (for example ${{ runner.temp }}/pi_key).

Acceptance criteria

  • ~/... key paths work on Linux, macOS, and Windows
  • A missing key file gives a clear auth error and leaves no pending timer
  • Unit test covers tilde expansion
  • e2e workflow uses an absolute key path

Getting started

  • Relevant files: mcp-server/src/utils/ssh-api.ts, .github/workflows/e2e.yml
  • How to run tests: cd mcp-server && npm install && npm test

Filed by repo-audit/full-audit at 9cfe5e3. Severity: high. Effort: S. audit-key: bug|mcp-server/src/utils/ssh-api.ts|execSSH.privateKey

Activity

  1. added
    bug
    good first issue
    severity: high
    on Nov 3, 2026
  2. ShahadatTest commented on Nov 3, 2026

    @ShahadatTest

    I'll take this — expand leading ~ in HOMELAB_PI_KEY_PATH / node key paths, wrap missing-key reads as SSHAuthError before arming the timer, and use an absolute path in e2e.

  3. TMHSDigital commented on Nov 3, 2026

    @TMHSDigital
    OwnerAuthor

    I'll take this — expand leading ~ in HOMELAB_PI_KEY_PATH / node key paths, wrap missing-key reads as SSHAuthError before arming the timer, and use an absolute path in e2e.

    I completely missed this, sorry! On the road but will review ASAP.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueseverity: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions