Secure Windows: Master OpenSSH Client & Server Configuration (Windows 11/10)

Table of Contents

The Secure Shell (SSH) protocol is a vital tool for secure remote communication. It functions by securely authenticating users and encrypting data transmission between a client and a server. This encryption ensures a significantly higher level of security compared to older protocols like Telnet, which transmits data in plain text. This guide will provide a comprehensive walkthrough on configuring and utilizing both the OpenSSH client and server on Windows 11 and Windows 10 operating systems.

Verifying OpenSSH Client Installation

Before proceeding with server configuration, it is crucial to verify the presence of the OpenSSH client on your Windows system. This ensures that the necessary components for SSH communication are in place. To check the installation, follow these steps:

  1. Open the Settings application by pressing the Windows key + I simultaneously.
  2. Within the Settings menu, navigate to and select the Apps category.
  3. In the Apps & features window, locate and click on the Optional features link, usually found on the right side of the window.
  4. Within the Optional features list, scroll down to find OpenSSH Client. If “OpenSSH Client” is listed, it is already installed, and no further action is required. If it is not listed, you will need to install it by clicking the “Install” button next to it.

Secure Windows: Master OpenSSH Client & Server Configuration

Installing OpenSSH Server

After confirming or installing the OpenSSH client, the next step is to install the OpenSSH server component. This will enable your Windows machine to act as an SSH server, allowing remote connections. To install the OpenSSH server, follow these steps:

  1. In the Optional features window, click on the Add a feature button, typically located at the top of the page.
  2. Scroll through the list of available features and locate OpenSSH Server.
  3. Select OpenSSH Server and click the Install button. Wait for a few moments while Windows installs the feature. The installation time may vary depending on your system and internet speed.
  4. Once the installation is complete, it is recommended to restart your computer to ensure all changes are properly applied and the OpenSSH server is fully functional.

Configuring SSH Server Startup

To ensure the OpenSSH server is readily available whenever your system boots, you need to configure its startup type to automatic. This ensures that the SSH server service starts automatically in the background after each system restart. Here’s how to configure automatic startup:

  1. Press Windows key + R to open the Run dialog box.
  2. Type services.msc in the Run dialog and press Enter. This will open the Services management console.
  3. In the Services window, scroll down to find OpenSSH SSH Server and OpenSSH Authentication Agent.
  4. Double-click on OpenSSH SSH Server. In the properties window, locate the Startup type dropdown menu and set it to Automatic. Click Apply and then OK.
  5. Repeat the previous step for OpenSSH Authentication Agent: Double-click, set Startup type to Automatic, and click Apply and OK.

Alternative Server Installation via Command Line

In some instances, the OpenSSH Server might not be listed in the Optional Features window, or the installation process might encounter issues. In such cases, you can utilize the command line to install the OpenSSH Server. This method offers an alternative approach to ensure the server is correctly installed.

  1. Open Command Prompt as an administrator. You can do this by searching for “cmd” in the Start menu, right-clicking on “Command Prompt”, and selecting “Run as administrator”.
  2. To verify the availability of the OpenSSH Server capability and identify its exact name, execute the following command:
    dism /online /get-capabilities | findstr /i "OpenSSH.Server"
    

    This command queries the system for available capabilities and filters the output to show entries related to “OpenSSH.Server”.
  3. Once you have confirmed the capability’s presence and name (typically “OpenSSH.Server~~0.0.1.0”), use the following command to install the OpenSSH Server:
    dism /online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0
    

    Execute this command in the elevated Command Prompt. The installation process will commence and may take a few moments.
  4. After successful execution, you do not need to restart your computer. Instead, return to the Services window (services.msc) and click on Action in the menu bar, then select Refresh. The OpenSSH SSH Server service should now be visible in the list.

Verifying SSH Service Status

After installing and configuring the OpenSSH server, it is essential to verify that the SSH services are running and active. This confirmation step ensures that the server is ready to accept incoming SSH connections. To check the service status, follow these steps:

  1. Right-click on the Start button and select Windows PowerShell (Admin) to open an elevated PowerShell window.
  2. In the PowerShell window, execute the following command to retrieve the status of SSH-related services:
    Get-Service -Name *ssh*
    

    This command queries the service manager and returns information about services with names containing “ssh”.
  3. The output will display the status of services like “OpenSSH SSH Server” and “OpenSSH Authentication Agent”. Ensure that the “Status” for “OpenSSH SSH Server” is listed as “Running”. If it is not running, you may need to start the service manually from the Services window (services.msc).

Configuring Windows Firewall for SSH Access

To allow SSH connections to your Windows machine, you must configure the Windows Firewall to permit traffic on the SSH port (default port 22). This firewall rule ensures that incoming SSH requests are not blocked. To configure the firewall, use the following command in the same elevated PowerShell window:

New-NetFirewallRule -Name SSHDPort -DisplayName 'OpenSSH SSH Server (TCP-In)' -Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow

This command adds a new firewall rule named “SSHD Port” that allows inbound TCP traffic on port 22, which is the standard port for SSH.

Testing SSH Server Listening Port

To further confirm that the SSH server is correctly configured and listening for connections, you can use the netstat command to check if port 22 is open and actively listening.

  1. In the elevated PowerShell window, execute the following command:
    netstat -bano | more
    

    This command lists active network connections and listening ports. The | more part is used to paginate the output for easier readability.
  2. Examine the output and look for a line that indicates TCP protocol, port 22, and a state of LISTENING. This line confirms that the SSH server is listening on port 22 and ready to accept connections.

Tip: If you do not see port 22 listed in the netstat output, it is advisable to restart your computer and then re-execute the netstat command after the system has fully booted. This restart can resolve potential issues with the service not starting correctly or firewall rules not being fully applied.

Connecting to the OpenSSH Server Remotely

With the OpenSSH server installed, configured, and verified, you can now establish remote connections to your Windows machine from other devices. To successfully connect via SSH, you will need the following information:

  1. Username: A valid user account on the Windows machine you are connecting to.
  2. Password: The password associated with the user account. Alternatively, you can configure SSH key-based authentication for passwordless login, which enhances security.
  3. Server IP Address: The IP address or hostname of your Windows machine. This is the address that the SSH client will use to locate and connect to your server. You can find your IP address using commands like ipconfig in Command Prompt or PowerShell.
  4. SSH Port: The port on which the SSH server is listening. By default, this is port 22. If you have changed the default port during server configuration, use the custom port number.

To initiate an SSH connection, open a terminal or command prompt on your client machine (this could be another Windows machine, macOS, Linux, etc.) and use the ssh command. The basic syntax is:

ssh username@server_ip_address -p port_number

For example, if your username is “user1”, your server’s IP address is “192.168.1.100”, and you are using the default port 22, the command would be:

ssh user1@192.168.1.100 -p 22

After executing the command, you will be prompted to enter the password for the specified user. Upon successful authentication, you will be logged into the remote Windows machine via SSH, and you will have a command-line interface to interact with the server. This secure connection ensures that all communication is encrypted, protecting your data from eavesdropping and unauthorized access.


Do you have any questions or experiences with configuring OpenSSH on Windows? Share your thoughts and tips in the comments below!

Post a Comment