Skip to content

[Bug]: --ssh-key-file flag is registered but never implemented — SSH keys silently not injected #93

Description

@mrhillsman

Bug Description

The --ssh-key-file CLI flag is registered (cmd/virtwork/main.go:90) but never consumed by resolveSSHKeys() in internal/config/config.go. Users who pass --ssh-key-file ~/.ssh/id_ed25519.pub get zero SSH keys injected into VMs. The flag is silently ignored with no error or warning.

resolveSSHKeys() only handles three sources:

  1. --ssh-key (inline public key strings)
  2. VIRTWORK_SSH_AUTHORIZED_KEYS env var (comma-split)
  3. ssh-authorized-keys YAML config list

It never reads --ssh-key-file, loads file contents from disk, or merges them into cfg.SSHAuthorizedKeys.

Steps to Reproduce

  1. Generate an SSH key: ssh-keygen -t ed25519 -f ~/.ssh/virtwork_ed25519 -N ""
  2. Run: virtwork run --workloads cpu --ssh-user virtwork --ssh-key-file ~/.ssh/virtwork_ed25519.pub --dry-run
  3. Inspect the generated cloud-init config — no SSH authorized keys are present
  4. Alternatively, deploy without --dry-run and attempt virtctl ssh — access is denied

Expected Behavior

--ssh-key-file should read the public key file(s) from disk and merge their contents into the SSHAuthorizedKeys list, so the keys are injected into VM cloud-init configs and SSH access works.

Actual Behavior

The flag is accepted without error but completely ignored. No SSH keys are injected. No warning is emitted. Users have no SSH access to VMs when relying solely on this flag.

The Phase 10 engineering journal explicitly acknowledges this was deferred: "flag exists for future use; --ssh-key (inline) works now" — but the README, configuration.md, development.md, chaos-workloads.md, the user guide, and the presentation demo script all document --ssh-key-file as the primary SSH workflow.

Affected documentation showing broken examples

  • README.md:92virtwork run --ssh-key-file ~/.ssh/id_ed25519.pub
  • docs/configuration.md:56-59
  • docs/development.md:31,659,679,745,750
  • docs/chaos-workloads.md:90,141,208
  • docs/guide/02-deploying-workloads.md:242,452,481
  • docs/plans/presentation/outline.md:88

Additional Context

The test at cmd/virtwork/main_test.go:243 only verifies the flag is parseable by Cobra, not that file contents are read or merged into config. A functional test that asserts file-based keys appear in cfg.SSHAuthorizedKeys is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.tech-debtTechnical debt, code quality, or maintenance concerntriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions