Skip to content

Instantly share code, notes, and snippets.

@EduardoThums
Created February 4, 2023 05:51
Show Gist options
  • Select an option

  • Save EduardoThums/f17ab7ba0afe131d65210f22b13fe180 to your computer and use it in GitHub Desktop.

Select an option

Save EduardoThums/f17ab7ba0afe131d65210f22b13fe180 to your computer and use it in GitHub Desktop.
# Commands taken from https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
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."
}
@EduardoThums
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment