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