Created
February 4, 2023 05:51
-
-
Save EduardoThums/f17ab7ba0afe131d65210f22b13fe180 to your computer and use it in GitHub Desktop.
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
| # 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." | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://cutt.ly/992Obbs