Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MousyBusiness/aaa8393f2c088a9a9f0643bf9dfee8ba to your computer and use it in GitHub Desktop.
Save MousyBusiness/aaa8393f2c088a9a9f0643bf9dfee8ba to your computer and use it in GitHub Desktop.
Powershell script to set administrator authorized key permissions
$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
@MousyBusiness
Copy link
Author

  1. open powershell with administrator privileges
  2. set script execution from powershell: set-executionpolicy remotesigned
  3. ./set-admin-authorized-keys-permissions.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment