$ErrorActionPreference = 'Stop'
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
$rule = Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue
if ($rule) {
$rule | Set-NetFirewallRule -Enabled True -RemoteAddress 192.168.167.191
} else {
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH diagnostic access' -Direction Inbound -Protocol TCP -LocalPort 22 -RemoteAddress 192.168.167.191 -Action Allow
}
Start-Service sshd
whoami
Get-Service sshd