Skip to content

init file from sshd_config_default on Windows#1474

Open
tgauth wants to merge 6 commits intoPowerShell:mainfrom
tgauth:fix-file-init
Open

init file from sshd_config_default on Windows#1474
tgauth wants to merge 6 commits intoPowerShell:mainfrom
tgauth:fix-file-init

Conversation

@tgauth
Copy link
Copy Markdown
Collaborator

@tgauth tgauth commented Apr 9, 2026

PR Summary

  • On Windows, if config file does not exist (and set command is specified), initialize the config file based on sshd_config_defaults file (from FOD install location).
  • Previously, in this scenario, the global sshd_config resource would initialize an empty file and the subsystem/subsystemList resources would error.

PR Context

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #1469 by changing how the sshdconfig resource behaves when the target sshd_config file is missing—on Windows, it attempts to seed the file from the system’s sshd_config_default so subsequent subsystem-related operations don’t fail due to an empty/nonexistent config.

Changes:

  • Added ensure_sshd_config_exists() to seed a missing sshd_config from sshd_config_default on Windows.
  • Updated set flows to require/ensure an existing config before applying non-purge updates and repeat-keyword updates.
  • Expanded Pester coverage to validate behavior when the target config file is missing.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
resources/sshdconfig/src/util.rs Adds seeding helper to create a missing target config from a Windows default source.
resources/sshdconfig/src/set.rs Calls the new seeding helper before reading/modifying config for non-purge and repeat operations.
resources/sshdconfig/locales/en-us.toml Adds new localized messages for seeding and missing-default-source scenarios.
resources/sshdconfig/tests/sshdconfig.set.tests.ps1 Updates/extends set tests for missing-file behavior.
resources/sshdconfig/tests/sshdconfigRepeat.tests.ps1 Adds repeat-keyword test for missing-file behavior.
resources/sshdconfig/tests/sshdconfigRepeatList.tests.ps1 Adds repeat-list test for missing-file behavior.
resources/sshdconfig/tests/sshdconfig.get.tests.ps1 Tightens get tests to ensure missing config doesn’t get created.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sshd resource fails if sshd_config doesn't exist

2 participants