Forked from CJavierSaldana/install-openssh-windows-server-2016.ps1
Created
May 23, 2024 08:19
-
-
Save ybagheri/417a26e5288237b2fc96b21f6bc719c8 to your computer and use it in GitHub Desktop.
Install OpenSSH on Windows Server 2016
This file contains 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
# Execute it with elevated permissions | |
# Description: | |
# This script install automatically the open-ssh feature and enable it | |
# enable tls1.2 for downloads | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# creating openssh folder and download the zip | |
mkdir c:\openssh-install | |
cd c:\openssh-install | |
#update the last version if you want the last release | |
Invoke-WebRequest -Uri "https://github.com/PowerShell/Win32-OpenSSH/releases/download/V8.6.0.0p1-Beta/OpenSSH-Win64.zip" -OutFile .\openssh.zip | |
Expand-Archive .\openssh.zip -DestinationPath .\openssh\ | |
cd .\openssh\OpenSSH-Win64\ | |
# required for enable the service | |
setx PATH "$env:path;c:\openssh-install\openssh\OpenSSH-Win64\" -m | |
# required for install the service | |
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1 | |
# required for execute remote connections | |
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 | |
net start sshd | |
# auto enable for each restart machine | |
Set-Service sshd -StartupType Automatic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment