• 在windows 上安装 openSSH


    一、基础环境

      操作系统:Microsoft Windows Server 2019 datacenter 64位

      openSSH 版本:OpenSSH_for_Windows_8.6p1, LibreSSL 3.3.3

    二、操作步骤

      1、【下载】从 https://github.com/PowerShell/Win32-OpenSSH/releases 下载最新的 OpenSSH安装包,如:openSSH-Win64.zip

      2、【解压】将压缩包解压到 C:\Program Files\OpenSSH

      3、【安装】【以管理员身份方式运行】 PowerShell 执行以下指令:

    PS C:\Users\Administrator> cd "C:\Program Files\OpenSSH"
    PS C:\Program Files\OpenSSH> powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
      [*] C:\Program Files\OpenSSH\moduli
    Inheritance is removed from 'C:\Program Files\OpenSSH\moduli'.
    'BUILTIN\Users' now has Read access to 'C:\Program Files\OpenSSH\moduli'.
    'APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES' now has Read access to 'C:\Program Files\OpenSSH\moduli'.
    'APPLICATION PACKAGE AUTHORITY\所有受限制的应用程序包' now has Read access to 'C:\Program Files\OpenSSH\moduli'.
          Repaired permissions
    
    [SC] SetServiceObjectSecurity 成功
    [SC] ChangeServiceConfig2 成功
    [SC] ChangeServiceConfig2 成功
    sshd and ssh-agent services successfully installed
    PS C:\Program Files\OpenSSH>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

      4、设置 防火墙(使用云主机的还需要在安全组中放行22端口)

    New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
    
    • 1

    &emsp 4.1、如果 win7/win2008 执行上面的命令报错请执行此处的命令

    netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
    
    • 1

      5、启动 OpenSSH

    PS C:\Program Files\OpenSSH> net start sshd
    OpenSSH SSH Server 服务正在启动 .
    OpenSSH SSH Server 服务已经启动成功。
    
    • 1
    • 2
    • 3

      6、设置开机自动启动

    Set-Service sshd -StartupType Automatic
    
    • 1

      8、操作全部完成。

    三、核心配置文件

      openSSH 的核心配置文件在 “C:\ProgramData\ssh\sshd_config”。

      修改配置文件后需要使用以下命令重启 openSSH 服务后才能生效。

    net stop sshd
    net start sshd
    
    • 1
    • 2

    四、常用操作

      查看ssh版本

    PS C:\Users\YangQun> ssh -V
    OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
    PS C:\Users\YangQun>
    
    • 1
    • 2
    • 3
  • 相关阅读:
    GDP-L-岩藻糖二钠盐,GDP-fucose ,6-Deoxy-β-L-galactopyranosylguanosine 5′-diphosphate
    switch语句深讲
    拿捏 顺序表(1)
    【机器学习】数据科学基础——机器学习基础实践(一)
    Standard part function
    【JAVA项目实战】【图书管理系统】登录模块【Servlet】+【Session】+【Filter】+【JSP】
    【宋红康 MySQL数据库 】【高级篇】【13】索引优化与查询优化
    my2sql工具之快速入门
    计算机毕业设计Java幼儿健康管理系统(系统+程序+mysql数据库+Lw文档)
    static应用知识:单例设计模式
  • 原文地址:https://blog.csdn.net/u011046671/article/details/126788743