OpenSSH之Windows安装OpenSSH

简介: OpenSSH之Windows安装OpenSSH


一、下载

笔者使用的是版本【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文件中的凭证。以上为就是笔者记录的OpenSSHWindows 中的安装操作流程。

三、参考链接

[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



相关文章
|
6月前
|
人工智能 JavaScript 开发工具
极速上手!Claude Code 原生支持 Windows 免WSL安装教程
Claude Code 现已支持 Windows 原生运行,无需 WSL 配置。本文提供详细安装教程,涵盖 Node.js 环境验证、Git 安装及 Claude Code 配置步骤,助你快速上手这一强大 AI 编程工具。
4724 5
|
6月前
|
存储 虚拟化 Windows
VMware安装Windows10
本案例介绍了在Windows系统上使用VMware Workstation 17.5 Pro安装配置Windows 10虚拟机的详细步骤,包括所需设备、软件下载链接、虚拟机设置及系统安装全过程。
2892 133
VMware安装Windows10
|
7月前
|
Ubuntu Unix Linux
在Windows上轻松安装和使用Ubuntu的方法详解
继续点击“Continue”按钮以继续安装流程,随后选择清理磁盘并安装操作系统的选项。 接下来,在安装过程中,你需要选择时区。为了与你的地理位置相匹配,请选择中国上海作为你的时区设置。 在安装过程中,你还需要设置计算机的名称以及账号密码。请务必牢记这些信息,因为它们将作为你登录系统的凭证。
|
5月前
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
242 3
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
|
6月前
|
安全 数据安全/隐私保护 Windows
ZyperWin++使用教程!让Windows更丝滑!c盘飘红一键搞定!ZyperWin++解决系统优化、Office安装和系统激活
ZyperWin++是一款仅5MB的开源免费Windows优化工具,支持快速优化、自定义设置与垃圾清理,兼具系统加速、隐私保护、Office安装等功能,轻便无广告,小白也能轻松上手,是提升电脑性能的全能管家。
1855 0
|
7月前
|
Ubuntu Linux Windows
如何在Ubuntu系统中安装Wine,借此来运行Windows程序
熟悉的登录画面出现,在Ubuntu系统中扫描登录微信程序。
|
7月前
|
Ubuntu Linux Shell
手把手教你安装适用于Linux的Windows子系统——Ubuntu
重启完成,你看看重新打开Ubuntu是不是发生了变化,等待几分钟,系统配置完成,根据提示设置用户名和密码即可
|
7月前
|
Ubuntu Linux 数据安全/隐私保护
Windows上快速安装Linux子系统Ubuntu
Installing, this may take a few minutes...WslRegisterDistribution failed with error: 0x800701bcError: 0x800701bc WSL 2 ?????????????????? https://aka.ms/wsl2kernelPress any key to continue... 原因是 wsl1 升级到 wsl2 之后,内核却没有升级。 解决:下载最新的wsl安装包(wsl安装包)

热门文章

最新文章