帮助链接:
安装 OpenSSH | Microsoft Learn
step1: 本机管理模式的power shell下查询安装状态
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
step2: 上面表示openssh server还没有安装,进行安装
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Install the OpenSSH Server
0 [main] install 16324 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer. Please report this problem to
the public mailing list cygwin@cygwin.com
/usr/bin/install: target `Server' is not a directory
PS C:\Users\pota> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Add-WindowsCapability : Add-WindowsCapability 失败。错误代码 = 0x80072f8f
所在位置 行:1 字符: 1
+ Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-WindowsCapability], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsCapabilityCommand
报错:
step3: 进入win11 “编辑组策略”, 计算机配置--管理模板--系统
点如下选项:指定可选组件安装和组件修复的设置
按如下配置,并点应用。
step3: 管理模式的power shell,重新安装
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
step 4:模式的power shell : Start-Service sshd
step5: ssh客户端访问