Install openSSH on windows

1. Basic environment

  Operating system: Microsoft Windows Server 2019 datacenter 64-bit

  openSSH version: OpenSSH_for_Windows_8.6p1, LibreSSL 3.3.3

2. Operation steps

  1. [Download] Download the latest OpenSSH installation package from https://github.com/PowerShell/Win32-OpenSSH/releases, such as: openSSH-Win64.zip

  2. [Decompression] Extract the compressed package to C:\Program Files\OpenSSH

  3. [Installation] [Run as administrator] PowerShell executes the following command:

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>

  4. Set up a firewall (if you use a cloud host, you also need to release port 22 in the security group)

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

&emsp 4.1. If win7/win2008 reports an error when executing the above command, please execute the command here.

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

  5. Start OpenSSH

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

  6. Set the boot to start automatically

Set-Service sshd -StartupType Automatic

  8. All operations are completed.

3. Core configuration file

  The core configuration file of openSSH is in "C:\ProgramData\ssh\sshd_config".

  After modifying the configuration file, you need to use the following command to restart the openSSH service to take effect.

net stop sshd
net start sshd

4. Common operations

  Check ssh version

PS C:\Users\YangQun> ssh -V
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
PS C:\Users\YangQun>

Guess you like

Origin blog.csdn.net/u011046671/article/details/126788743