使用管理员权限打开Windows PowerShell
- Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
- 启动服务
Start-Service sshd
设置开机自启
Set-Service sshd -StartupType Automatic - 允许22端口
New-NetFirewallRule -Name “SSH” -DisplayName “SSH” -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 - 使用命令查看服务状态
Get-Service sshd - 查看22端口监听状态
netstat -ano | findstr :22 - 检查防火墙规则
Get-NetFirewallRule -Name “SSH” - 必要时重新安装SSH
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0