问题:无法在Windows PowerShell 7.2.6中发出命令Start-Service sshd。
预期结果: OpenSSH服务器启动。
实际结果: Start-Service: Cannot find any service with service name 'sshd'..
上面的Investigation:错误清除表明OpenSSH服务器没有安装。
根问题:发出Add-WindowsCapability -Online -Name OpenSSH.Server~~~0.0.1.0似乎没有安装OpenSSH服务器。
验证OpenSSH服务器没有通过上面的命令安装:
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在Windows10上安装OpenSSH服务器时,我是否遗漏了什么?
尝试:卸载和重新安装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通过这个问题,虽然不同,他们似乎能够安装它。(接受是一个很好的选择,如果我不能做到这一点,但我更愿意跟随Win32 32-OpenSSH GitHub或微软官方资源)
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类似问题,但是我没有安装Cygwin。
Alternative:安装通过GUI或通过Git克隆。(我想使用PS)。
附加信息:
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资料来源: firstuse?tabs=powershell
发布于 2022-09-05 00:49:37
根据亚伯拉罕·齐纳拉斯的评论。
溶液
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成功启动!
https://stackoverflow.com/questions/73603594
复制相似问题