This repository has been archived on 2026-07-09. You can view files and clone it, but cannot push or open issues or pull requests.
agent-knowledge-base-archived/problems/2026-05-24-windows-openssh-admin-authorized-keys.md
2026-05-24 15:38:29 +03:00

1.5 KiB

Windows OpenSSH Admin Users Need ProgramData Authorized Keys

Symptoms

On pump, OpenSSH Server was installed, running, and listening on TCP 22, but key login failed:

Permission denied (publickey,password,keyboard-interactive).

The public key existed in C:\Users\post\.ssh\authorized_keys.

Root Cause

The default Windows OpenSSH config contains:

Match Group administrators
       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

For a local administrator account such as post, sshd checks C:\ProgramData\ssh\administrators_authorized_keys instead of the user profile file.

Fix

From an elevated PowerShell:

$adminKeys = "$env:ProgramData\ssh\administrators_authorized_keys"
New-Item -ItemType Directory -Force -Path (Split-Path $adminKeys) | Out-Null
Get-Content "$env:USERPROFILE\.ssh\authorized_keys" | Set-Content $adminKeys -Encoding ascii
icacls $adminKeys /inheritance:r
icacls $adminKeys /grant "SYSTEM:F" "Administrators:F"
icacls $adminKeys /remove "Users" "Authenticated Users" "Everyone"
Restart-Service sshd

Copy only public keys. Never commit private keys.

Verification

On pump, after this fix:

ssh -i C:\Users\post\.ssh\pump_local_ssh_ed25519 -o IdentitiesOnly=yes -o BatchMode=yes post@localhost hostname
ssh -i C:\Users\post\.ssh\pump_local_ssh_ed25519 -o IdentitiesOnly=yes -o BatchMode=yes post@192.168.1.39 hostname

Both returned PUMP.

  • skills/windows-remote-access-baseline.md
  • locations/pump.md