Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheBigBear/631e097641e911a30e3d9b8f5f8f0a0b to your computer and use it in GitHub Desktop.
Save TheBigBear/631e097641e911a30e3d9b8f5f8f0a0b to your computer and use it in GitHub Desktop.
Set permissions ACL for Windows OpenSSH administrators_authorized_keys
# this script is copied from:
# https://www.concurrency.com/blog/may-2019/key-based-authentication-for-openssh-on-windows
# Script by Mitchell Grande of Concurrency.com
#
$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment