Add sshdconfig set for "regular" keywords & clobber = true#1275
Merged
SteveL-MSFT merged 14 commits intoPowerShell:mainfrom Dec 3, 2025
Merged
Add sshdconfig set for "regular" keywords & clobber = true#1275SteveL-MSFT merged 14 commits intoPowerShell:mainfrom
SteveL-MSFT merged 14 commits intoPowerShell:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements the set command functionality for the sshdconfig resource, focusing on support for clobber: true mode with regular (non-repeatable, non-multi-arg) SSH configuration keywords. The implementation includes comprehensive validation using sshd -T, automatic backup of existing non-DSC-managed configurations, and integration of the -s (setting) parameter to distinguish between sshd_config and windows-global settings.
Key Changes
- Added
set_sshd_configfunction that creates temporary config files, validates them withsshd -T, backs up existing configs if not DSC-managed, and writes the new configuration - Refactored filepath handling from
StringtoPathBufthroughout the codebase for better type safety - Added comprehensive Pester tests covering valid configurations, backup creation, DSC-managed file detection, and error handling scenarios
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/sshdconfig/tests/sshdconfig.set.tests.ps1 | New comprehensive test suite for sshd_config set operations, testing valid configs, backup behavior, and error cases |
| resources/sshdconfig/tests/defaultshell.tests.ps1 | Updated all set command calls to include -s windows-global flag; corrected test name for empty string handling |
| resources/sshdconfig/sshd-windows.dsc.resource.json | Added -s windows-global arguments to set command configuration |
| resources/sshdconfig/src/util.rs | Added get_default_sshd_config_path helper, refactored to use PathBuf, added get_bool_or_default helper for cleaner boolean extraction |
| resources/sshdconfig/src/set.rs | Implemented set_sshd_config function with temp file validation, backup logic, and DSC header detection; updated set_default_shell signature |
| resources/sshdconfig/src/metadata.rs | Added constants for DSC header and default config paths for both Unix and Windows |
| resources/sshdconfig/src/main.rs | Updated set command to pass setting parameter to invoke_set |
| resources/sshdconfig/src/inputs.rs | Added clobber field to CommandInfo; changed filepath types from String to PathBuf |
| resources/sshdconfig/src/args.rs | Added required setting parameter to Set command with hidden flag |
| resources/sshdconfig/locales/en-us.toml | Added new localization strings for set operations, debug messages, and error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SteveL-MSFT
requested changes
Dec 2, 2025
SteveL-MSFT
approved these changes
Dec 3, 2025
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.
PR Summary
clobber: trueand regular keyword (no objects/arrays yet)setcommand: create temp file based on input, validate temp file usingsshd -T, back-up any existing sshd_config file (only if it is not already managed by this resource), then update/create sshd_config file