Disable inherit on key file for parent ACL rules

This commit is contained in:
Chris Roberts 2018-06-12 16:21:13 -07:00
parent ae8e25aabc
commit e39b3555e6
1 changed files with 3 additions and 1 deletions

View File

@ -15,8 +15,10 @@ function Set-SSHKeyPermissions {
# Create the new ACL we want to apply # Create the new ACL we want to apply
$NewAccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule( $NewAccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
$Principal, "FullControl", "None", "None", "Allow") $Principal, "FullControl", "None", "None", "Allow")
# Scrub all existing ACLs from the file
$ACL = Get-ACL "${SSHKeyPath}" $ACL = Get-ACL "${SSHKeyPath}"
# Disable inherited rules
$ACL.SetAccessRuleProtection($true, $false)
# Scrub all existing ACLs from the file
$ACL.Access | %{$ACL.RemoveAccessRule($_)} $ACL.Access | %{$ACL.RemoveAccessRule($_)}
# Apply the new ACL # Apply the new ACL
$ACL.SetAccessRule($NewAccessRule) $ACL.SetAccessRule($NewAccessRule)