![cover](https://img-blog.csdnimg.cn/d80bcf16f4224eb180dd2fa15a780878.png)
OpenSSH之Windows安装OpenSSH
在Windows10中安装OpenSSH的基本流程。
![blog-SSHd-Header](https://i-blog.csdnimg.cn/blog_migrate/8afcc954105bc268b0124ed3d04c25b1.png)
一、下载
笔者使用的是版本【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 : 无法加载文件 xxxxx\install-sshd.ps1,因为在此系统上禁止运行脚本
修改策略:
> get-executionpolicy
Restricted
> set-executionpolicy remotesigned
再次运行脚本,操作如下:
> .\install-sshd.ps1
[*] C:\Program Files (x86)\OpenSSH-Win64\moduli
Inheritance is removed from 'C:\Program Files (x86)\OpenSSH-Win64\moduli'.
'BUILTIN\Users' now has Read access to 'C:\Program Files (x86)\OpenSSH-Win64\moduli'.
'APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES' now has Read access to 'C:\Program Files (x86)\OpenSSH-Win64\moduli'.
'APPLICATION PACKAGE AUTHORITY\所有受限制的应用程序包' now has Read access to 'C:\Program Files (x86)\OpenSSH-Win64\moduli'.
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
更多推荐
所有评论(0)