SIGN IN

    OpenSSH is a tool that allows you to remotely manage your server via the command line. While previously using SSH on Windows required the installation of third-party programs, OpenSSH can now be installed right on Windows Server 2019. In this article, we will show you how to do that.

     

    Step 1: Download the OpenSSH distribution

    Go to OpenSSH-Server-Package~31bf3856ad364e35~amd64~~.cab  and download the version intended for Windows Server 2019. (Do not rename the *.cab file) 

     

    Step 2: Placement and Unpacking

    Compared to Windows 2012 and Windows 2016, the installation of this OpenSSH package will be different. In this article, we will do most of the work in the PowerShell console. In order for the installation to be successful, download the file OpenSSH-Server-Package~31bf3856ad364e35~amd64~~.cab and place it in the root of your C drive

    .

     

    Step 3: Install via PowerShell

    Run PowerShell as an administrator. Run the following commands:

      

    Install the downloaded *.cab package:

     Dism /Online /Add-Package /PackagePath: "C:\OpenSSH-Server-Package~31bf3856ad364e35~amd64~~.cab"

     

    After successful installation you will see the following message: 

     

    If the installation was successful, we can remove it:

     Remove-Item "C:\OpenSSH-Server-Package~31bf3856ad364e35~amd64~~.cab"-Force

     

     

    Step 4: Firewall Configuration

    OpenSSH uses TCP port 22. To allow access to the server through this port, add a rule to Windows Firewall:

       New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH 

    You can also do this manually through the GUI using the "Windows Firewall with Advanced Security" snap-in. But if you have done this correctly, port 22 should open itself after OpenSSH is installed.

     

    Step 5: Activate the OpenSSH service

    Open the list of services by typing services.msc. Find "OpenSSH SSH Server", navigate to the service properties, set the service to auto-start, and start the service.

     

     

     

    Or you can run the following command in the PowerShell console, it will start the SSH service and set it to start automatically on system startup.

     

    Start-Service -Name sshd
    
    Set-Service -Name sshd -StartupType Automatic 

     

    Step 6: Verify Port

    To verify that port 22 is active, run the command:

     netstat -a | findstr "22"

    If port 22 is listening, it means everything is configured correctly.

     

    If necessary, you can also set the default PowerShell console for the SSH shell.

     

     New-ItemProperty -Path "HKLM:/SOFTWARE / OpenSSH" -Name DefaultShell -Value "C:Windows / System32 / WindowsPowerShell / v1.0 /powershell.exe" -PropertyType String -Force 

     

    Step 7: Verify OpenSSH

    Now try connecting to the server from another computer, or even the same computer, using the command:

      ssh [username]@[server IP_address] 

    If everything has been configured correctly, you should be able to successfully connect to the server.

     

    Closure

    Now you have OpenSSH configured on Windows Server 2019 and you can manage your server remotely without any problems. Remember to regularly check for updates to OpenSSH to ensure your system is secure.