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
| $ErrorActionPreference = 'Stop' | |
| Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | Out-Null | |
| Set-Service sshd -StartupType Automatic | |
| Start-Service sshd | |
| New-NetFirewallRule -DisplayName 'OpenSSH-22' -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow -ErrorAction SilentlyContinue | Out-Null | |
| $key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUDZ0sROmkXnJXKu00pS3+Q5WHZHBHWXKqVK5LC3XM80Kr/sh08RrzXeeD+5t/XpRgfSXoAFUfLDFqLkALaWjcAGbmzvdMy0ri095IwDR/2HMC57yNtIiaAyV1/o6LlpN58CJ93lYOBnm1YMEJdSWoJeE6o6mQmB29v0xuvTePY4mcaGQGH6wsyOXx2NXcd+LJkDjB2eYBlg+M4FqIdAFqlo3DnbMHNgvCX9v5HV8aRKGyo7t07A773lA/3qy3VVdElYgkTdOJsRbfvnBg/6tTvF0ZaqebrqomiKG93J6Yfi15fFbHBSFrmvC6PMXQ5skxyD34VFAYzHJubcMgSVld dev-box-binh' | |
| $keyFile = 'C:\ProgramData\ssh\administrators_authorized_keys' | |
| Set-Content -Path $keyFile -Value $key -Encoding ASCII -NoNewline | |
| icacls $keyFile /inheritance:r /grant 'Administrators:F' 'SYSTEM:F' | Out-Null | |
| if (-not (Test-Path 'HKLM:\SOFTWARE\OpenSSH')) { New-Item -Path 'HKLM:\SOFTWARE\OpenSSH' -Force | Out |