Skip to content

Instantly share code, notes, and snippets.

@scivision
Created August 11, 2020 17:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scivision/76ea29409ddee521ad5bebe19d1c96ce to your computer and use it in GitHub Desktop.
Save scivision/76ea29409ddee521ad5bebe19d1c96ce 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