Setting up OpenSSH on Windows Server 2016

- 2 minutes read - 226 words
  • Download the latest –zip– file from Github
    • Run script on server to download the file:
PS C:\> Invoke-WebRequest https://githu -OutFile
  • Extract the files from the zip file:
PS C:\> Expand-Archive .\ 'C:\Program Files\'
  • Update the Enviroment Path:
PS C:\> ($env:path).split(“;”)
PS C:\> $oldpath = (Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PATH).path
PS C:\> $newpath = “$oldpath;C:\Program Files\OpenSSH-Win64\”
PS C:\> Set-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PATH -Value $newPath
  • Can use the following command to create a temporary path:

  • Restart Powershell / Server for changes to take effect.

  • Confirm that OpenSLL is listed within the enviroment path:

PS C:\> ($env:path).split(“;”)
  • Open Powershell and set the current directory to OpenSSL:
PS C:\> cd 'C:\Program Files\OpenSSH-Win64\'
  • Execute the –.\install-sshd.ps1– script:
PS C:\Program Files\OpenSSL-Win64> .\install-sshd.ps1
  • Generate SSH host-key:
PS C:\Program Files\OpenSSL-Win64> .\ssh-keygen.exe -A
  • Start the SSHD service:
PS C:\> Start-Service -Name sshd
  • Set the service to start on boot:
PS C:\> Set-Service -Name "sshd" -StartupType automatic
PS C:\> Get-WMIObject win32_service -Filter "name = 'sshd'"
PS C:\> Get-WMIObject win32_service | Format-Table Name, StartMode -auto
  • Open up the Firewall port for SSH:
PS C:\> netsh advfirewall firewall add rule name="Open Port 22" dir=in action=allow protocol=TCP localport=22


    comments powered by Disqus