Add SSH port and passphrase support with config migration - #87
Merged
Conversation
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
gensyn
September 1, 2026 09:20
View session
gensyn
marked this pull request as ready for review
September 1, 2026 09:30
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
passphrase can be forwarded even when no key_file is configured and port currently lacks schema coercion/range validation, which can result in inconsistent or invalid ssh_command.execute payloads.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends the ssh_docker Home Assistant integration to support SSH port and passphrase across config flow, options flow, discovery prefill, SSH service payload construction, and config entry migration from version 1 → 2.
Changes:
- Added
portandpassphrasefields to config/options flows and localized strings, with defaults (22/ empty string). - Threaded
portthroughssh_command.executepayloads and forwardedpassphraseconditionally when set. - Introduced config entry migration to backfill missing
portandpassphraseon legacy entries, plus unit tests covering migration and payload behavior.
File summaries
| File | Description |
|---|---|
translations/en.json |
Adds English UI labels/descriptions for port and passphrase. |
translations/de.json |
Adds German UI labels/descriptions for port and passphrase. |
strings.json |
Adds base strings for port and passphrase across config/options forms. |
README.md |
Documents new config options and discovery behavior for port/passphrase. |
const.py |
Introduces CONF_PORT, CONF_PASSPHRASE, and defaults. |
options_flow.py |
Adds fields + wires port/passphrase into validation/service payload and stored options. |
config_flow.py |
Bumps flow VERSION to 2, adds fields to schemas, and forwards port/passphrase for validation/existence checks. |
coordinator.py |
Threads port/passphrase into runtime SSH execution payloads. |
__init__.py |
Adds async_migrate_entry and includes port/passphrase in discovery prefill data. |
tests/unit_tests/test_options_flow.py |
Updates options-flow tests and adds coverage for passphrase omission/inclusion + port forwarding. |
tests/unit_tests/test_init.py |
Adds migration tests and updates fixtures to include new defaults. |
tests/unit_tests/test_config_flow.py |
Extends discovery/payload tests for port and passphrase. |
Review details
Suppressed comments (2)
options_flow.py:167
- The
portfield in the options form schema should coerce and validate the port range (1-65535) to prevent invalid values from being saved.
vol.Required(CONF_HOST, default=current.get(CONF_HOST, "")): str,
vol.Optional(CONF_PORT, default=current.get(CONF_PORT, DEFAULT_PORT)): int,
vol.Required(CONF_USERNAME, default=current.get(CONF_USERNAME, "")): str,
config_flow.py:147
- The pre-filled user schema for config flow should also coerce/validate
port(1-65535) so discovery/user re-renders can't accept invalid values.
vol.Required(CONF_NAME, default=defaults.get(CONF_NAME, "")): str,
vol.Required(CONF_SERVICE, default=defaults.get(CONF_SERVICE, "")): str,
vol.Required(CONF_HOST, default=defaults.get(CONF_HOST, "")): str,
vol.Optional(CONF_PORT, default=defaults.get(CONF_PORT, DEFAULT_PORT)): int,
vol.Required(CONF_USERNAME, default=defaults.get(CONF_USERNAME, "")): str,
- Files reviewed: 12/12 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…passphrase' into copilot/add-ssh-parameters-port-passphrase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates
ssh_dockerto support the newssh_command.executeinputsportandpassphrase, including backward-compatible migration for existing entries. Existing configs are migrated toport=22andpassphrase="", while discovery preserves the discovered/original port.Config + options surface
port(afterhost) andpassphrase(afterkey_file) to config flow, options flow, and localized form strings.port=22,passphrase=""port,passphraseprefilled from source options (or empty)SSH payload wiring
portthrough all SSH service payload construction paths.passphraseforwarding: only included inssh_command.executepayload when non-empty.Entry migration
2.async_migrate_entryto inject missing fields into legacy entries:port: 22passphrase: ""Documentation
portandpassphrase, including conditional passphrase forwarding.