Windows Server 2016 安装OpenSSH
1. 下载 OpenSSH
https://github.com/PowerShell/Win32-OpenSSH/releases

2. 解压到 C:\Program Files\OpenSSH-Win64
3. 运行命令提示符(管理员),使用cd命令到步骤3中文件夹OpenSSH的位置,然后输入命令后回车: powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1

4. 步骤3成功后,继续如下的命令后回车: netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
。

5. 然后使用命令打开sshd。如下: net start sshd
6. net stop sshd
停止服务。
7. 禁用密码登陆:修改 C:\ProgramData\ssh\sshd_config
。添加一行:PasswordAuthentication no
8. 设置管理员用户公钥:添加 C:\ProgramData\ssh\administrators_authorized_keys 文件,文件内容为共钥,
9. 最后打开sshd。如下: net start sshd
PS:Windows Server 2019、Windows 10、Windows Server 2022 安装 OpenSSH 请看 https://docs.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse
参考资料:
最后更新于