# SSH 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`.&#x20;

%Home%\\.ssh\ also contains the user **config** file for setting Host aliases and other SSH settings.&#x20;

## Configuration

### sshd\_config

#### SubSystem - Powershell

{% hint style="warning" %}
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\`**
{% endhint %}

To enable the Powershell subsystem, add this line to **sshd\_config :**&#x20;

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

## Reference

### Microsoft Docs

{% embed url="<https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse>" %}
