Skip to content

Instantly share code, notes, and snippets.

@CJavierSaldana
Created September 16, 2021 13:35
Show Gist options
  • Save CJavierSaldana/3b328ac85bb767e03861a4b01fe6a0cb to your computer and use it in GitHub Desktop.
Save CJavierSaldana/3b328ac85bb767e03861a4b01fe6a0cb to your computer and use it in GitHub Desktop.
Install OpenSSH on Windows Server 2016
# 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
@CJavierSaldana
Copy link
Author

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/CJavierSaldana/3b328ac85bb767e03861a4b01fe6a0cb/raw/37ef071cd531305c72e8e567dc8c393740e2d3d5/install-openssh-windows-server-2016.ps1'))

@cyborgkali426
Copy link

Very well, my friend.

@NiccoDorn
Copy link

You know, that everything about this whole thing looks suspicious as hell?

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