Search code examples
windowssshopenssh

How to generate Windows OpenSSH default config file?


I'd like to know where is the default OpenSSH config file ("sshd_config" for Linux) or if not exists how to generate the file.

I thought SSH setting file "sshd_config" and "config" is the same format and same files, but apparently they are not. Because I copy and pasted C:\Windows\System32\OpenSSH\sshd_config_default to C:/Users/user/.ssh/config and I didn't work, and I got an error it says the format is invalid:

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

So, I'd like to know what the Windows OpenSSH default config file looks like. Without knowing it, I have no idea and cannot change lines to change the SSH setting.


Solution

  • Following PowerShell/Win32-OpenSSH issue 1297, you should simply modify C:\Windows\System32\OpenSSH\sshd_config_default and then restart the SSH service.

    No need to copy it/rename it elsewhere (except, may be, to keep the original version)

    The %USERPROFILE%\.ssh\config file is used only on the client side, not by the SSH server/service.

    As noted in "Unable to get public-key login to work on Windows 10 ssh server", the sshd_config can be added in:

    C:\ProgramData\ssh\sshd_config