如何生成 Windows OpenSSH 默认配置文件?

How to generate Windows OpenSSH default config file?

我想知道默认的 OpenSSH 配置文件(Linux 的“sshd_config”)在哪里,或者如果不存在如何生成文件。

我以为SSH设置文件“sshd_config”和“config”是相同的格式和相同的文件,但显然它们不是。因为我将 C:\Windows\System32\OpenSSH\sshd_config_default 复制并粘贴到 C:/Users/user/.ssh/config 但我没有工作,而且我得到一个错误,它说格式无效:

PS C:\Users\tmp> ssh user@192.168.0.123
C:\Users\tmp/.ssh/config: line 38: Bad configuration option: authorizedkeysfile
C:\Users\tmp/.ssh/config: line 76: Bad configuration option: subsystem
Unsupported Match attribute Group
C:\Users\tmp/.ssh/config line 84: Bad Match condition

所以,我想知道 Windows OpenSSH 默认配置文件是什么样的。在不知情的情况下,我不知道也无法更改线路来更改 SSH 设置。

按照PowerShell/Win32-OpenSSH issue 1297,您只需修改C:\Windows\System32\OpenSSH\sshd_config_default,然后重启SSH服务即可。

不需要复制it/rename它到别处(除非,可能是为了保留原始版本)

%USERPROFILE%\.ssh\config 文件仅在客户端使用,SSH 不使用 server/service。

如“Unable to get public-key login to work on Windows 10 ssh server”中所述,可将 sshd_config 添加到:

C:\ProgramData\ssh\sshd_config