windows ssh
OpenSSH Server on a Windows host, key-only, reachable the way windows_access says.
Contract
- Manages: the OpenSSH Server capability and its
sshdservice; a marked block at the top ofsshd_config(key logins on, password logins off when an admin key exists);administrators_authorized_keys; the SSH default shell; the SSH firewall rules. - Leaves alone: the rest of
sshd_config(the vendor lines stay as they are), host keys, per-userauthorized_keys, and any other firewall rule. - Change it in: the fleet’s
config/vars/(for examplevars/group/all.yml, or the host’s file). Defaults are inrole.ps1; the sharedwindows_accessandwindows_tailnet_rangesare inwindows/defaults.yml. - Rolls back by: a change to
sshd_configis validated withsshd -tfirst, a copy is kept assshd_config.consigliere-bak, and ifsshddoes not come back listening on port 22 the copy is restored and the run fails with that said. - Check mode: reports what it would change and changes nothing.
The access policy
Section titled “The access policy”windows_access is one switch for Remote Desktop and SSH together:
| Value | SSH | Remote Desktop |
|---|---|---|
tailnet (default) |
Port 22 allowed only from windows_tailnet_ranges; the any-source OpenSSH rule is turned off. |
Same, by the baseline role. |
lan |
The standard OpenSSH rule is on (any source, as Windows sets it); the tailnet-only rule is removed. | Windows’ own rules. |
Tailscale SSH is not an option here: Windows cannot be a Tailscale SSH server, so this is plain OpenSSH behind a firewall rule. The rule is made before the old one is turned off, so a session that arrived over the old rule is never cut off by the change.
Variables
Section titled “Variables”| Variable | Default | Meaning |
|---|---|---|
windows_ssh_manage |
true |
false leaves SSH entirely alone. |
windows_ssh_password_auth |
false |
Password logins. Never switched off while no admin key exists, so the role cannot lock a host out. |
windows_ssh_default_shell |
pwsh |
The shell a login gets: pwsh (PowerShell 7), powershell (5.1) or cmd. |
windows_access |
tailnet |
tailnet or lan (see above). |
windows_tailnet_ranges |
Tailscale’s IPv4 and IPv6 ranges | What tailnet means. |
baseline_admin_ssh_keys, baseline_bastion_ssh_keys |
the fleet’s | The keys written to administrators_authorized_keys (the same variables as the Linux baseline). |
- Administrators’ keys on Windows are in
C:\ProgramData\ssh\administrators_authorized_keys, not in a profile; sshd refuses the file unless only SYSTEM and Administrators can read it, which the role sets. - Installing the capability downloads it through Windows Update, so the host needs to reach Microsoft’s servers. VERIFY on the VM.
- Not verified on Windows: every cmdlet here. The
sshd_configblock logic was tested apart from Windows.