Skip to content

Instantly share code, notes, and snippets.

@Udara-Dananjaya
Created October 11, 2023 17:25
Show Gist options
  • Save Udara-Dananjaya/85f99f93e099c5d0a5be70696c9c445c to your computer and use it in GitHub Desktop.
Save Udara-Dananjaya/85f99f93e099c5d0a5be70696c9c445c to your computer and use it in GitHub Desktop.
Configuring OpenSSH Server on Windows using PowerShell

OpenSSH is a popular open-source tool that allows secure remote administration of your Windows system. This guide demonstrates how to install and configure the OpenSSH Server on a Windows machine using PowerShell commands.

  1. Check if OpenSSH is already installed:

    • where ssh is used in Command Prompt (CMD) to check if OpenSSH is already installed. This command will search for the SSH executable.
  2. Check and Install OpenSSH in PowerShell:

    • In PowerShell, you can use the following commands to check if OpenSSH is available and install it if not.
    • Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' lists the available OpenSSH capabilities.
    • Add-WindowsCapability -Online -Name OpenSSH.Server* installs the OpenSSH Server feature.
    • Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' is run again to verify the installation.
  3. Start the OpenSSH Server service:

    • Start-Service sshd is used to start the OpenSSH Server service.
  4. Set OpenSSH Server service to Automatic startup:

    • Set-Service -Name sshd -StartupType 'Automatic' sets the OpenSSH Server service to start automatically when the system boots.
  5. Stop the OpenSSH Server service (optional):

    • net stop sshd is an optional command to stop the OpenSSH Server service.

Remember to run these commands with administrative privileges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment