Created
September 1, 2023 21:18
-
-
Save joelsdc/d774f05f0ea1a43c77e9b935a536e3f5 to your computer and use it in GitHub Desktop.
Windows OpenSSH Install via PowerShell
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
# Install the OpenSSH Client | |
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 | |
# Install the OpenSSH Server | |
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | |
# Start the sshd service | |
Start-Service sshd | |
# Autostart sshd service | |
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." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment