Last active 1 month ago

win2016-openssh.ps1 Raw
1# Run as Admin in PowerShell
2
3# Download and extract OpenSSH-Win64
4mkdir C:\openssh-install
5cd C:\openssh-install
6[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
7Invoke-WebRequest -Uri "https://github.com/PowerShell/Win32-OpenSSH/releases/latest/download/OpenSSH-Win64.zip" -OutFile .\openssh.zip
8Expand-Archive .\openssh.zip -DestinationPath .\openssh\
9Move-Item .\openssh\OpenSSH-Win64 "C:\Program Files\OpenSSH-Win64" -Force
10
11# Add to system PATH
12setx PATH "$env:path;C:\Program Files\OpenSSH-Win64\" -m
13
14# Install the sshd + ssh-agent services
15cd "C:\Program Files\OpenSSH-Win64"
16powershell.exe -ExecutionPolicy Bypass -File .\install-sshd.ps1
17
18# Generate host keys
19mkdir C:\ProgramData\ssh
20.\ssh-keygen.exe -A
21
22# Fix file perms
23.\FixHostFilePermissions.ps1 -Confirm:$false
24
25# Service
26Set-Service sshd -StartupType Automatic
27Set-Service ssh-agent -StartupType Automatic
28Start-Service sshd
29Start-Service ssh-agent