- 一、下载
- 二、 脚本安装
- 2.1、执行脚本
- 2.2 查看服务
- 三、参考链接
一、下载
笔者使用的是版本【8.6.0.0p1-Beta】,以下为在线地址:
https://github.com/PowerShell/Win32-OpenSSH/releases/download/V8.6.0.0p1-Beta/OpenSSH-Win64.zip
二、 脚本安装 2.1、执行脚本启动Powershell,切换到下载包解压路径:
> .install-sshd.ps1 .install-sshd.ps1 : 无法加载文件 xxxxxinstall-sshd.ps1,因为在此系统上禁止运行脚本
修改策略:
> get-executionpolicy Restricted > set-executionpolicy remotesigned
再次运行脚本,操作如下:
> .install-sshd.ps1
[*] C:Program Files (x86)OpenSSH-Win64moduli
Inheritance is removed from 'C:Program Files (x86)OpenSSH-Win64moduli'.
'BUILTINUsers' now has Read access to 'C:Program Files (x86)OpenSSH-Win64moduli'.
'APPLICATION PACKAGE AUTHORITYALL APPLICATION PACKAGES' now has Read access to 'C:Program Files (x86)OpenSSH-Win64moduli'.
'APPLICATION PACKAGE AUTHORITY所有受限制的应用程序包' now has Read access to 'C:Program Files (x86)OpenSSH-Win64moduli'.
Repaired permissions
[SC] SetServiceObjectSecurity 成功
[SC] ChangeServiceConfig2 成功
[SC] ChangeServiceConfig2 成功
sshd and ssh-agent services successfully installed
2.2 查看服务
退出Powershell,管理员权限执行cmd,启动对应sshd服务
>sc query sshd
SERVICE_NAME: sshd
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
>sc start sshd
SERVICE_NAME: sshd
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 3480
FLAGS :
>sc query sshd
SERVICE_NAME: sshd
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 3480
FLAGS :
Open SSH服务默认启动时,若未指定配置文件生成路径,默认生成路径为%programdata%ssh,
服务启动成功后,访问端口为ssh默认端口22,当前系统中测试访问,当前系统登录账户能够默认远程访问,打开cmd,执行远程连接指令:
>ssh -p 22 [username]@[host] The authenticity of host '[host]:22 ([host]:22)' can't be established. ECDSA key fingerprint is SHA256:bNEEFJF1EAWTDRvW4iU/19u0XXUOlwRb20U/d64K7Wc. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[host]:22' (ECDSA) to the list of known hosts. [username]@[host]'s password: Microsoft Windows [版本 10.0.19043.928] (c) Microsoft Corporation。保留所有权利 >
username为当前登录用户,host为当前主机局域网ip,-p port默认是22端口时,可以不用添加
ECDSA key fingerprint is SHA256:bNEEFJF1EAWTDRvW4iU/19u0XXUOlwRb20U/d64K7Wc为[username]/.ssh/known_hosts文件中的凭证。以上为就是笔者记录的OpenSSH 在 Windows 中的安装操作流程。
三、参考链接[1] OpenSSH For Windows官方文档:
https://github.com/PowerShell/Win32-OpenSSH/wiki/sshd_config
[2]微软官方文档:
https://docs.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_server_configuration



