Skip to content

Install OpenSSH

On Windows 11 after upgrading the service did not start reporting "System error 1067 has occurred.". It seems that the problem is because of the C:\ProgramData\ssh\logs directory permissions.
Removint this directory allows starting of OpenSSH service.

Capabilities

List the capabilities matching OpenSSH*.

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Using Powershell command line and execute the following to enable the Windows capabilities.

As of writing, version 0.0.1.0.
So check the latest versions.

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

SSH Daemon Config

Modify file %PROGRAMDATA%\ssh\sshd_config.

notepad %PROGRAMDATA%\ssh\sshd_config

Comment out the next lines located at the bottom of the file.
Since the first user is also an administrator.

Match Group administrators
       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

Change file entry at the beginning named AuthorizedKeysFile as follows to use in the Cygwin folder located .ssh directory.

AuthorizedKeysFile %h/cygwin/.ssh/authorized_keys

Change the DefautShell string value in the registry or create it when it does not exist.

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\cygwin64\sshd.bat" -PropertyType String -Force

When done restart the sshd service.

Using powershell.

Set-Service -Name sshd -StartupType 'Automatic'
Restart-Service sshd

Instead, use the command prompt.

net stop sshd & net start sshd

Unblock sshd Service Port 22

# Create a firewall rule to allow Port 22
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Configure Cygwin Shell

Create the batch file %SystemDrive%\cygwin64\sshd.bat with the following content.
It sets the home directory for the Cygwin bash session by calling the existing Cygwin.bat file.

@echo off
set HOME=%HOMEDRIVE%%HOMEPATH%\cygwin
call %~dp0Cygwin.bat

Debugging

Run the sshd.exe with option -ddd where the amount of D's stands vor the level of debugging.