-
Notifications
You must be signed in to change notification settings - Fork 61
Add reference documentation for Microsoft.OpenSSH.SSHD/Windows #934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gijsreyn
wants to merge
6
commits into
PowerShell:main
Choose a base branch
from
Gijsreyn:reference-doc-sshdconfig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bccc898
Initial reference documentation for Microsoft.OpenSSH.SSHD/Windows
Gijsreyn fcf49ed
Update with latest changes
Gijsreyn 40d6808
Add sshd_config
Gijsreyn 2da7de4
Update Copilot remarks and adding two more examples
Gijsreyn a3f5f97
Order
Gijsreyn fc9176a
Take suggestion
Gijsreyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...s/Microsoft/OpenSSH/SSHD/Windows/examples/configure-default-shell-powershell.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| --- | ||
| description: > | ||
| Example showing how to use Microsoft.OpenSSH.SSHD/Windows to configure the default shell for SSH sessions. | ||
| ms.date: 07/15/2025 | ||
| ms.topic: reference | ||
| title: Configure default shell for SSH | ||
| --- | ||
|
|
||
| # Configure default shell for SSH | ||
|
|
||
| This example demonstrates how to use the `Microsoft.OpenSSH.SSHD/Windows` resource to | ||
| set the default shell for SSH connections. The examples below configure PowerShell | ||
| as the default shell for all SSH sessions. | ||
|
|
||
| > [!NOTE] | ||
| > You should run this example in an elevated context (as Administrator) to | ||
| > ensure the SSH server configuration can be updated successfully. | ||
|
|
||
| ## Test the current default shell | ||
|
|
||
| The following snippet shows how you can use the resource with the [dsc resource test][00] command to check whether PowerShell is set as the default shell. | ||
|
|
||
| ```powershell | ||
| $instance = @{ | ||
| shell = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' | ||
| } | ConvertTo-Json | ||
|
|
||
| dsc resource test --resource Microsoft.OpenSSH.SSHD/Windows --input $instance | ||
| ``` | ||
|
|
||
| When PowerShell is not set as the default shell, DSC returns the following result: | ||
|
|
||
| ```yaml | ||
| desiredState: | ||
| shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | ||
| actualState: {} | ||
| inDesiredState: false | ||
| differingProperties: | ||
| - shell | ||
| ``` | ||
|
|
||
| ## Set PowerShell as the default shell | ||
|
|
||
| To set PowerShell as the default shell for SSH, use the [dsc resource set][01] command. | ||
|
|
||
| ```powershell | ||
| dsc resource set --resource Microsoft.OpenSSH.SSHD/Windows --input $instance | ||
| ``` | ||
|
|
||
| When the resource updates the default shell, DSC returns the following result: | ||
|
|
||
| ```yaml | ||
| beforeState: {} | ||
| afterState: | ||
| shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | ||
| changedProperties: | ||
| - shell | ||
| ``` | ||
|
|
||
| You can test the instance again to confirm that PowerShell is now the default shell: | ||
|
|
||
| ```powershell | ||
| dsc resource test --resource Microsoft.OpenSSH.SSHD/Windows --input $instance | ||
| ``` | ||
|
|
||
| ```yaml | ||
| desiredState: | ||
| shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | ||
| actualState: | ||
| shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | ||
| inDesiredState: true | ||
| differingProperties: [] | ||
| ``` | ||
|
|
||
| ## Cleanup | ||
|
|
||
| To restore your system to its original state, use the following command to delete the registry key: | ||
|
|
||
| ```powershell | ||
| $params = @{ | ||
| Path = 'HKLM:\SOFTWARE\OpenSSH' | ||
| Name = 'DefaultShell' | ||
| ErrorAction = 'SilentlyContinue' | ||
| } | ||
| Remove-ItemProperty @params | ||
| ``` | ||
|
|
||
| To verify the configuration is removed, use the `dsc resource get` command: | ||
|
|
||
| ```powershell | ||
| dsc resource get --resource Microsoft.OpenSSH.SSHD/Windows --input $instance | ||
| ``` | ||
|
|
||
| ```yaml | ||
| actualState: {} | ||
| ``` | ||
|
|
||
| <!-- Link reference definitions --> | ||
| [00]: ../../../../../cli/resource/test.md | ||
| [01]: ../../../../../cli/resource/set.md |
199 changes: 199 additions & 0 deletions
199
docs/reference/resources/Microsoft/OpenSSH/SSHD/Windows/index.md
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
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,199 @@ | ||||||||||
| --- | ||||||||||
| description: Microsoft.OpenSSH.SSHD/Windows resource reference documentation | ||||||||||
| ms.date: 07/02/2025 | ||||||||||
| ms.topic: reference | ||||||||||
| title: Microsoft.OpenSSH.SSHD/Windows | ||||||||||
| --- | ||||||||||
|
|
||||||||||
| # Microsoft.OpenSSH.SSHD/Windows | ||||||||||
|
|
||||||||||
| ## Synopsis | ||||||||||
|
|
||||||||||
| Manage SSH server global configuration settings on Windows. | ||||||||||
|
|
||||||||||
| ## Metadata | ||||||||||
|
|
||||||||||
| ```yaml | ||||||||||
| Version : 0.1.0 | ||||||||||
| Kind : resource | ||||||||||
| Tags : [OpenSSH, Windows] | ||||||||||
| Author : Microsoft | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Instance definition syntax | ||||||||||
|
|
||||||||||
| ```yaml | ||||||||||
| resources: | ||||||||||
| - name: <instance name> | ||||||||||
| type: Microsoft.OpenSSH.SSHD/Windows | ||||||||||
| properties: | ||||||||||
| # Instance properties | ||||||||||
| shell: | ||||||||||
| cmdOption: | ||||||||||
| escapeArguments: | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Condition | ||||||||||
|
|
||||||||||
| The resource only applies on systems where the `sshd` executable is available in PATH. DSC | ||||||||||
| evaluates this with the expression `[not(equals(tryWhich('sshd'), null()))]` and skips the | ||||||||||
| resource if `sshd` is not found. | ||||||||||
|
|
||||||||||
| ## Description | ||||||||||
|
|
||||||||||
| The `Microsoft.OpenSSH.SSHD/Windows` resource enables you to idempotently manage the Windows | ||||||||||
| OpenSSH server global settings. These settings are stored in the Windows registry under | ||||||||||
| `HKLM\SOFTWARE\OpenSSH` and control the default shell behavior for SSH sessions: | ||||||||||
|
|
||||||||||
| - Set the default shell executable for SSH connections. | ||||||||||
| - Specify command-line options to pass to the default shell. | ||||||||||
| - Control whether shell arguments are escaped. | ||||||||||
|
|
||||||||||
| > [!NOTE] | ||||||||||
| > This resource is installed with DSC itself on systems. | ||||||||||
| > | ||||||||||
| > You can update this resource by updating DSC. When you update DSC, the updated version of this | ||||||||||
| > resource is automatically available. | ||||||||||
|
|
||||||||||
| ## Requirements | ||||||||||
|
|
||||||||||
| - The resource requires OpenSSH server and client to be installed on the Windows system. | ||||||||||
| - The resource must run in a process context that has permissions to manage the SSH server | ||||||||||
| configuration settings. | ||||||||||
| - The resource must run at least under a Windows Server 2019 or Windows 10 (build 1809) | ||||||||||
| operating system. | ||||||||||
|
Comment on lines
+63
to
+64
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Comment on lines
+58
to
+64
|
||||||||||
|
|
||||||||||
| ## Capabilities | ||||||||||
|
|
||||||||||
| The resource has the following capabilities: | ||||||||||
|
|
||||||||||
| - `get` - You can use the resource to retrieve the actual state of an instance. | ||||||||||
| - `set` - You can use the resource to enforce the desired state for an instance. | ||||||||||
|
|
||||||||||
| This resource uses the synthetic test functionality of DSC to determine whether an instance is in | ||||||||||
| the desired state. For more information about resource capabilities, see | ||||||||||
| [DSC resource capabilities][00]. | ||||||||||
|
|
||||||||||
| ## Examples | ||||||||||
|
|
||||||||||
| 1. [Configure default shell PowerShell][01] - Shows how to set the default shell to PowerShell.exe | ||||||||||
|
|
||||||||||
| ## Properties | ||||||||||
|
|
||||||||||
| The following list describes the properties for the resource. | ||||||||||
|
|
||||||||||
| - **Instance properties:** <a id="instance-properties"></a> The following properties are optional. | ||||||||||
| They define the desired state for an instance of the resource. | ||||||||||
|
|
||||||||||
| - [shell](#shell) - The path to the default shell for SSH. | ||||||||||
| - [cmdOption](#cmdOption) - Specifies command-line options for the shell. | ||||||||||
| - [escapeArguments](#escapeArguments) - Specifies whether shell arguments should be escaped. | ||||||||||
|
|
||||||||||
| ### shell | ||||||||||
|
|
||||||||||
| <details><summary>Expand for <code>shell</code> property metadata</summary> | ||||||||||
|
|
||||||||||
| ```yaml | ||||||||||
| Type : string, null | ||||||||||
| IsRequired : false | ||||||||||
| IsKey : false | ||||||||||
| IsReadOnly : false | ||||||||||
| IsWriteOnly : false | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| </details> | ||||||||||
|
|
||||||||||
| Defines the path to the default shell executable to use for SSH sessions. | ||||||||||
| When specified, the value must be a valid path to an executable on the system. | ||||||||||
|
|
||||||||||
| ### cmdOption | ||||||||||
|
|
||||||||||
| <details><summary>Expand for <code>cmdOption</code> property metadata</summary> | ||||||||||
|
|
||||||||||
| ```yaml | ||||||||||
| Type : string, null | ||||||||||
| IsRequired : false | ||||||||||
| IsKey : false | ||||||||||
| IsReadOnly : false | ||||||||||
| IsWriteOnly : false | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| </details> | ||||||||||
|
|
||||||||||
| Specifies optional command-line options to pass to the shell when it's launched. | ||||||||||
|
|
||||||||||
| ### escapeArguments | ||||||||||
|
|
||||||||||
| <details><summary>Expand for <code>escapeArguments</code> property metadata</summary> | ||||||||||
|
|
||||||||||
| ```yaml | ||||||||||
| Type : boolean, null | ||||||||||
| IsRequired : false | ||||||||||
| IsKey : false | ||||||||||
| IsReadOnly : false | ||||||||||
| IsWriteOnly : false | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| </details> | ||||||||||
|
|
||||||||||
| Determines whether shell arguments should be escaped. When set to `true`, the arguments will be | ||||||||||
| properly escaped before being passed to the shell. | ||||||||||
|
|
||||||||||
| ## Instance validating schema | ||||||||||
|
|
||||||||||
| The resource generates its schema dynamically at runtime by running | ||||||||||
| `sshdconfig schema -s windows-global`. The following snippet shows the effective schema that | ||||||||||
| validates an instance of the resource. | ||||||||||
|
|
||||||||||
| ```json | ||||||||||
| { | ||||||||||
| "type": "object", | ||||||||||
| "properties": { | ||||||||||
| "shell": { | ||||||||||
| "type": [ | ||||||||||
| "string", | ||||||||||
| "null" | ||||||||||
| ] | ||||||||||
| }, | ||||||||||
| "cmdOption": { | ||||||||||
| "type": [ | ||||||||||
| "string", | ||||||||||
| "null" | ||||||||||
| ] | ||||||||||
| }, | ||||||||||
| "escapeArguments": { | ||||||||||
| "type": [ | ||||||||||
| "boolean", | ||||||||||
| "null" | ||||||||||
| ] | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Exit codes | ||||||||||
|
|
||||||||||
| The resource returns the following exit codes from operations: | ||||||||||
|
|
||||||||||
| - [0](#exit-code-0) - Success | ||||||||||
| - [1](#exit-code-1) - Invalid parameter | ||||||||||
|
|
||||||||||
| ### Exit code 0 | ||||||||||
|
|
||||||||||
| Indicates the resource operation completed without errors. | ||||||||||
|
|
||||||||||
| ### Exit code 1 | ||||||||||
|
|
||||||||||
| Indicates the resource operation failed due to an invalid parameter. When the resource returns this | ||||||||||
| exit code, it also emits an error message with details about the invalid parameter. | ||||||||||
|
|
||||||||||
| ## See also | ||||||||||
|
|
||||||||||
| - [Microsoft.DSC/PowerShell resource][02] | ||||||||||
| - For more information about OpenSSH, see [OpenSSH Documentation][03] | ||||||||||
|
|
||||||||||
| <!-- Link definitions --> | ||||||||||
| [00]: ../../../../../concepts/resources/capabilities.md | ||||||||||
| [01]: ./examples/configure-default-shell-powershell.md | ||||||||||
| [02]: ../../../DSC/PowerShell/index.md | ||||||||||
| [03]: /windowsserverdocs/WindowsServerDocs/administration/OpenSSH/openssh-overview | ||||||||||
|
Gijsreyn marked this conversation as resolved.
|
||||||||||
81 changes: 81 additions & 0 deletions
81
...ces/Microsoft/OpenSSH/SSHD/sshd_config/examples/export-openssh-configuration.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| --- | ||
| description: > | ||
| Example showing how to use Microsoft.OpenSSH.SSHD/sshd_config to export current SSH server | ||
| configuration settings. | ||
| ms.date: 05/07/2026 | ||
| ms.topic: reference | ||
| title: Export OpenSSH SSH server configuration | ||
| --- | ||
|
|
||
| # Export OpenSSH SSH server configuration | ||
|
|
||
| This example demonstrates how to use the `Microsoft.OpenSSH.SSHD/sshd_config` resource with the | ||
| [dsc resource export][00] command to retrieve all current SSH server configuration settings as a | ||
| DSC configuration document that you can save and re-apply later. | ||
|
|
||
| > [!NOTE] | ||
| > You should run this example in an elevated context (as Administrator on Windows, or as root on | ||
| > Linux) to ensure the SSH server configuration can be read successfully. | ||
|
|
||
| ## Export the current SSH server configuration | ||
|
|
||
| Run the following command to export the current `sshd_config` settings: | ||
|
|
||
| ```powershell | ||
| dsc resource export --resource Microsoft.OpenSSH.SSHD/sshd_config | ||
| ``` | ||
|
|
||
| DSC returns a configuration document with one resource instance per exported setting. The output | ||
| looks similar to the following, where the exact properties and values reflect what is currently | ||
| configured on the system: | ||
|
|
||
| ```yaml | ||
| $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
| - name: Microsoft.OpenSSH.SSHD/sshd_config[0] | ||
| type: Microsoft.OpenSSH.SSHD/sshd_config | ||
| properties: | ||
| port: '22' | ||
| addressfamily: any | ||
| listenaddress: '0.0.0.0' | ||
| syslogfacility: AUTH | ||
| loglevel: INFO | ||
| logingracetime: 120 | ||
| strictmodes: 'yes' | ||
| maxauthtries: 6 | ||
| pubkeyauthentication: 'yes' | ||
| authorizedkeysfile: .ssh/authorized_keys | ||
| passwordauthentication: 'no' | ||
| permitemptypasswords: 'no' | ||
| challengeresponseauthentication: 'no' | ||
| kerberosauthentication: 'no' | ||
| gssapiauthentication: 'no' | ||
| usepam: 'yes' | ||
| x11forwarding: 'no' | ||
| printmotd: 'no' | ||
| acceptenv: LANG LC_* | ||
| subsystem: sftp /usr/lib/openssh/sftp-server | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > The output is truncated in this example. The actual output includes all effective | ||
| > `sshd_config` directives for your system, including defaults inherited from OpenSSH. | ||
|
|
||
| ## Save the export to a configuration file | ||
|
|
||
| You can pipe the export output to a file to create a backup of your current SSH server | ||
| configuration: | ||
|
|
||
| ```powershell | ||
| dsc resource export --resource Microsoft.OpenSSH.SSHD/sshd_config > sshd_backup.dsc.config.yaml | ||
| ``` | ||
|
|
||
| To re-apply the saved configuration to a system, use the [dsc config set][01] command: | ||
|
|
||
| ```powershell | ||
| dsc config set --document sshd_backup.dsc.config.yaml | ||
| ``` | ||
|
|
||
| <!-- Link reference definitions --> | ||
| [00]: ../../../../../../cli/resource/export.md | ||
| [01]: ../../../../../../cli/config/set.md |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.