Windows 2019安装OpenSSH Server

2023-03-08  本文已影响0人  CodingCode

OpenSSH在windows 2019里作为一个可选部件,缺省并没有安装。

  1. 通过PowerShell命令行
  1. 获取OpenSSH相关的两个(client和server)包名字
> 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 : 1323493
InstallSize  : 5301402

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 : 1297677
InstallSize  : 4946932
  1. 安装
> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

这里名字OpenSSH.Server~~~~0.0.1.0由上一个命令获取。

注意如果不需要client,则也可以不安装,不过顺手都装了得了。

  1. 验证安装成功
> Get-Service ssh*

Status   Name               DisplayName
------   ----               -----------
Stopped  ssh-agent          OpenSSH Authentication Agent
Stopped  sshd               OpenSSH SSH Server

如果安装不成功,遇到问题:Add-WindowsCapability failed. RSAT Error code = 0x800f0954,那么参考:https://thesysadminchannel.com/solved-add-windowscapability-failed-error-code-0x800f0954-rsat-fix/

  1. 设置server启动属性,并启动
> Set-Service -Name sshd -StartupType Automatic
> Set-Service -Name ssh-agent -StartupType Automatic

> Start-Service sshd
> Start-Service ssh-agent
  1. 通过控制面板

Windows ”start menu“ => "setting" => "apps" => "apps & features" => "manage optional features" => "add a feature" => scroll to 'OpenSSL XXX' => click install.

安装完之后,他们会出现在"已经安装的features"里面。

然后到"service"里面设置sshd和ssh-agent的启动模式,并且启动他们。

上一篇 下一篇

猜你喜欢

热点阅读