SSH on Windows

Configuring and Using OpenSSH on Windows

Config File Locations

sshd_config

In Windows, sshd reads configuration data from %programdata%\ssh\sshd_config (i.e.: C:\ProgramData\ssh\sshd_config).

A different configuration file may be specified by launching sshd.exe with the -f parameter. If the file is absent, sshd generates one with the default configuration when the service is started.

AuthorizedKeysFile & User Config

Default location for authorized_keys is %Home%\.ssh\authorized_keys. This is usually C:\Users\<UserName>\.ssh\authorized_keys.

%Home%\.ssh\ also contains the user config file for setting Host aliases and other SSH settings.

Configuration

sshd_config

SubSystem - Powershell

Due to a bug in Windows, sshd_config can not contain directories with spaces in it, (ex: C:\Program Files). To find the Short Name Filename, use dir /x. For example, C:\Program Files\Powershell\ translates to C:\PPROGRA~1\POWERS~1\

To enable the Powershell subsystem, add this line to sshd_config :

Subsystem       powershell      C:\PPROGRA~1\POWERS~1\6\pwsh.exe -sshs -NoLogo -NoProfile

Reference

Microsoft Docs

Last updated