Home > OS >  I am Unable to start OpenSSH with Windows PowerShell
I am Unable to start OpenSSH with Windows PowerShell

Time:09-07

Problem: Unable to issue command Start-Service sshd in Windows PowerShell 7.2.6.

Expected Results: OpenSSH Server Starts.

Actual Results: Start-Service: Cannot find any service with service name 'sshd'..

Investigation: Above error clearing indicates OpenSSH Server is not installed.

Root Problem: Issuing Add-WindowsCapability -Online -Name OpenSSH.Server~~~0.0.1.0 does not appear to install OpenSSH server.

Verifying OpenSSH Server is not installing via above command:

PowerShell 7.2.6

PS > Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

PS > Add-WindowsCapability -Online -Name OpenSSH.Server~~~0.0.1.0

Path          :
Online        : True
RestartNeeded : False

PS > Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Am I missing anything with trying to installing OpenSSH Server on Windows 10?

Attempted: Uninstall and Reinstall OpenSSH.Server.

PowerShell 7.2.6

PS > Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Path          :
Online        : True
RestartNeeded : False

PS > Add-WindowsCapability -Online -Name OpenSSH.Server~~~0.0.1.0

Path          :
Online        : True
RestartNeeded : False

PS > Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Via this question although different they seem to be able to install it. (Accepted is a good alternative if I cant get this working, however I would prefer following either Win32-OpenSSH GitHub or the Official Microsoft Resource)

PowerShell 7.2.6

PS > Get-WindowsCapability -Online -Name OpenSSH.Server~~~0.0.1.0

Name         :
State        : NotPresent
DisplayName  :
Description  :
DownloadSize : 0
InstallSize  : 0

PS > Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

PS > Add-WindowsCapability -Online -Name OpenSSH.Server*

Path          :
Online        : True
RestartNeeded : False

PS > Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Similar Issue, however I do not have Cygwin Installed.

Alternative: Install via GUI or via Git clone. (I would like to use PS).

Additional Info:

PowerShell 7.2.6

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

>winver.exe

Version 21H2
OS Build 19044.1889

Source: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell

CodePudding user response:

As per Abraham Zinalas Comment.

Solution

PS > Get-WindowsCapability -Online -Name open* | Add-WindowsCapability -Online

Path          :
Online        : True
RestartNeeded : False

Path          :
Online        : True
RestartNeeded : False


PS > Get-WindowsCapability -Online -Name open*

Name         : OpenSSH.Client~~~~0.0.1.0
State        : Installed
DisplayName  : OpenSSH Client
Description  : OpenSSH-based secure shell (SSH) client, for secure key management and access to
               remote machines.
DownloadSize : 1314377
InstallSize  : 10602592

Name         : OpenSSH.Server~~~~0.0.1.0
State        : Installed
DisplayName  : OpenSSH Server
Description  : OpenSSH-based secure shell (SSH) server, for secure key management and access from
               remote machines.
DownloadSize : 1290075
InstallSize  : 9894430

PS > Start-Service sshd
PS > 

sshd successfully started!

  • Related