Skip to content

beszel-agent: -k <path-to-keyfile> always fails with 'ssh: no key found' — only inline key values parse #2764

Closed

Description

@BeauBoorman

Description

beszel-agent fails to start when the hub public key is passed as a file path to -k/--key, with a parse error that misleads you into thinking the key file is corrupt:

$ beszel-agent -k /etc/beszel/hub.pub -t <token>
Failed to load public keys:failed to parse key: /etc/beszel/hub.pub, error: ssh: no key found

Repro (agent 0.21.1, linux/amd64, NixOS)

  1. Generate a perfectly valid key: ssh-keygen -t ed25519 -N "" -f /tmp/fk
  2. beszel-agent -k /tmp/fk.pub -t x → Failed to load public keys:failed to parse key: /tmp/fk.pub, error: ssh: no key found
  3. Same with the hub's own key file (id_ed25519.pub copied from the hub's beszel_data), with and without trailing newline — same error.
  4. Pass the key inline: beszel-agent -k "$(cat /tmp/fk.pub)" -t x → starts fine (Data directory detected, SSH server starts).

Same behavior reproduced with the current henrygd/beszel-agent image (--key /tmp/fk.pub fails, --key "$(cat ...)" works), so this is not fixed in latest.

Expected behavior

Either:

  • -k <path> reads the file and parses the key, or
  • the error message says file-path values are not supported, pass the key inline.

Right now the message ("failed to parse key: ") points at the key material being invalid, which cost us a while diagnosing a key that was byte-identical to the hub's.

Notes

The README/systemd examples show -k <path> style usage (KEY_FILE env var is accepted too — didn't test whether that path works). If only literal key values are supported, the flag help (-k, --key string Public key(s) for SSH authentication) should say so.

Versions: agent 0.21.1 binary (pre-staged release download) and current henrygd/beszel-agent:latest image (digest sha256:cb68680…), hub 0.21.x on linux.

Activity

  1. svenvg93 commented on Nov 5, 2026

    @svenvg93
    Collaborator

    -k/--key and KEY take the key value itself, not a path, so the path gets parsed as a key and you see ssh: no key found. To load the key from a file, use KEY_FILE:

    KEY_FILE=/etc/beszel/hub.pub TOKEN=<token> beszel-agent
    

    -k and KEY take precedence over KEY_FILE, so remove them when you switch. I tested this on current main.

    The error message and flag help should make this clearer, I will improve the message.

  2. added
    awaiting-requester
    on Nov 5, 2026
  3. locked and limited conversation to collaborators on Nov 20, 2026
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

    awaiting-requester

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions