# OPTIONAL but recommended: Set-Service-Name sshd -StartupType'Automatic'
設定 SSH 伺服器防火牆
1 2 3 4 5 6 7
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify if (!(Get-NetFirewallRule-Name"OpenSSH-Server-In-TCP"-ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { Write-Output"Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." New-NetFirewallRule-Name'OpenSSH-Server-In-TCP'-DisplayName'OpenSSH Server (sshd)'-Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort22 } else { Write-Output"Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." }