windows 安裝 OpenSSH 服務
下載程序
- github 地址 https://github.com/PowerShell/Win32-OpenSSH
- release https://github.com/PowerShell/Win32-OpenSSH/releases
- https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win64.zip
安裝 OpenSSH
wiki https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH
- 把文件解壓至 C:\Program Files\OpenSSH
- 打開 powershell
- cd C:'Program Files'\OpenSSH
- powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
- 打開sshd.exe的防火牆,以允許入站SSH連接
$ New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
注意:新的NetFirewallRule僅適用於Windows 2012及更高版本的服務器。如果您使用的是客戶端桌面計算機(如Windows 10)或Windows 2008 R2及以下版本,請嘗試:
$ netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22 - 啓動sshd
$ net start sshd - 設置開機啓動
$ Set-Service sshd -StartupType Automatic