Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In the following steps, you will use Azure Policy to deploy SSH Posture Control settings to a test Windows Server 2019, 2022, or 2025 VM.
For background and conceptual reference, see What is SSH Posture Control?.
For a more advanced walkthrough, see Manage your sshd settings using SSH Posture Control.
If you don't have an Azure account, you can create a free trial.
Caution
- This Quickstart demonstrates applying a restrictive sshd configuration intended for a new disposable test machine. If you were to apply this configuration to other machines you could lock outself out. When trying out security controls such as SSH Posture Control, use an isolated sandbox environment such that even a mistake in policy assignment would not re-configure unintended machines.
Prerequisites
Before attempting the steps in this article, ensure that you already have:
- An Azure account where you have rights to create a resource group, policy assignments, and a virtual machine.
- Your preferred environment for interacting with Azure, such as:
- Azure Cloud Shell (recommended)
- Note: Examples will use bash mode. Readers may adapt examples to other shell environments including PowerShell.
- or your own shell environment with Azure CLI installed and signed in
- or Azure Portal in a web browser
- Azure Cloud Shell (recommended)
Check that you are signed in to your test environment
Use the account information in the portal to see your current context.
Create a resource group
The choice of eastus location in this example is not significant. You can use any available Azure location.
Assign the policy to the resource group
This Quickstart applies audit-and-configure behavior, using the built-in policy definition [Preview]: Configure SSH security posture for Windows.
The example assignment will rely largely on SSH Posture Control defaults (e.g., port 22, root access not allowed), with limited customization (banner text).
- Navigate to Policy, then Definitions
- Filter the list to find and select
[Preview]: Configure SSH security posture for Windows - From the policy definition page, click Assign
- In the policy assignment workflow
- Choose the new empty resource group (created earlier) as the scope.
- Optional: Choose a name for this policy assignment. By default the name of the policy definition is used.
- Optional: On the parameters tab, override a default value such as the "banner" value.
- Note: The rule 'port' should be configured with a single value to ensure proper functionality and compliance for auditing and configuring scenarios.
- Complete the creation of the policy assignment.
Caution
Whether you used the Portal or CLI, inspect the scope of the policy assignment you just created before proceeding. If the scope was mistakenly set to anything other than the new empty resource group created earlier, it should be corrected immediately to avoid configuing unintended machines.
Create a test VM and prepare it for Machine Configuration
- Create a Windows Server 2019, 2022, or 2025 virtual machine
- Add a system assigned identity, if not already present
- Add the Machine Configuration extension (labeled in portal as Azure Machine Configuration for Windows)
Tip
In this Quickstart the pre-requisites for Machine Configuration (VM has managed identity and agent extension) were addressed directly during VM creation. At scale, these pre-requisites can be satisfied using the Deploy prerequisites to enable Guest Configuration policies on virtual machines built-in Policy Initiative.
Take a break before proceeding
Several steps will now happen automatically. Each of these steps can take a few minutes. Accordingly, please wait at least 15 minutes before proceeding.
Observe results
Using the following steps, you can see:
- How many machines are compliant (or not)
- Particularly useful at production scales, where you may have thousands of machines
- Which machines are compliant (or not)
- For a given machine, which individual rules are compliant (or not)
Optional: Add more test machines to experience scale
In this article the policy was assigned to a resource group which was initially empty and then gained one VM. While this demonstrates the system working end-to-end, it doesn't provide a sense of at-scale operations. For example, in the policy assignment compliance view a pie chart of one machine can feel artificial.
Consider adding more test machines to the resource group, whether manually or via automation. These could be Azure VMs or Arc-enabled machines. As you see those machines come into compliance (or even fail) you can gain a keener sense of operationalizing SSH Posture Control at scale.
Optional: Manually inspect test machine to confirm results
When getting started with a new feature such as SSH Posture Control, it can be valuable to manually inspect the results out of band. This helps to build confidence and clarity. The steps in this article, for example, should have resulted in a modified logon banner configuration on your test VM. You can confirm this by attempting an SSH connection to the machine to see the banner, or by inspecting the sshd_config file.
Clean up resources
To avoid ongoing charges, consider deleting the resource group used in this article. For example, the Azure CLI command would be az group delete --name "sshdemo01"
Getting started with the Local Experience (PowerShell)
Prerequisites
- You must be running a production-signed Windows Server 2019, 2022, 2025 build on your device.
- The OSConfig PowerShell module must be installed on your server device. See Install the OSConfig PowerShell module for details.
- You must have sshd service installed and running following this guide: https://aka.ms/windows-openssh-install.
To apply a baseline, verify that the baseline is applied, remove a baseline, or view detailed compliance information for OSConfig in PowerShell, use the commands on the following tabs.
Configure
To apply the SSH scenario, run the following command:
Set-OSConfigDesiredConfiguration -Scenario SSH -Default
Verify
To verify that the SSH scenario is properly applied, run the following command:
Get-OSConfigDesiredConfiguration -Scenario SSH
Check compliance
To obtain the desired configuration details for the specified scenario, use the following commands. The output appears in a table format that includes the name of the configuration item, its compliance status, and the reason for noncompliance.
To check the compliance details for SSH scenairo, run the following command:
Get-OSConfigDesiredConfiguration -Scenario SSH | ft Name, @{ Name = "Status"; Expression={$_.Compliance.Status} }, @{ Name = "Reason"; Expression={$_.Compliance.Reason} } -AutoSize -Wrap
Custom Configuration
To custom the setting in SSH scenario, you can configure a setting with parameter '-Name' and '-Value':
Set-OSConfigDesiredConfiguration -Scenario SSH -Name Banner -Value "Custom Banner"
Next steps
Contact the team at Microsoft to provide feedback, features requests, etc.