From 096c42053c260adb964e9ffbb0a9d75c6fbbbc1a Mon Sep 17 00:00:00 2001 From: USER Date: Wed, 27 Sep 2023 21:10:35 +0100 Subject: [PATCH] . --- bin/Firewall.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/Firewall.ps1 b/bin/Firewall.ps1 index 0925a68..66cc49f 100755 --- a/bin/Firewall.ps1 +++ b/bin/Firewall.ps1 @@ -1,3 +1,15 @@ -New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 +# New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Set-Service sshd -StartupType Automatic \ No newline at end of file +Set-Service sshd -StartupType Automatic# Start the sshd service +Start-Service sshd + +# OPTIONAL but recommended: +Set-Service -Name sshd -StartupType 'Automatic' + +# 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 -LocalPort 22 +} else { + Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." +} \ No newline at end of file