OpenSSH在windows 2019里作为一个可选部件,缺省并没有安装。
- 通过PowerShell命令行
- 获取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
- 安装
> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
这里名字OpenSSH.Server~~~~0.0.1.0
由上一个命令获取。
注意如果不需要client,则也可以不安装,不过顺手都装了得了。
- 验证安装成功
> 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/
- 设置server启动属性,并启动
> Set-Service -Name sshd -StartupType Automatic
> Set-Service -Name ssh-agent -StartupType Automatic
> Start-Service sshd
> Start-Service ssh-agent
- 通过控制面板
Windows ”start menu“ => "setting" => "apps" => "apps & features" => "manage optional features" => "add a feature" => scroll to 'OpenSSL XXX' => click install.
安装完之后,他们会出现在"已经安装的features"里面。
然后到"service"里面设置sshd和ssh-agent的启动模式,并且启动他们。
网友评论