From 0fc8b61fdc64df8dfa370c79f94ed16140109b44 Mon Sep 17 00:00:00 2001 From: dechert Date: Wed, 2 Nov 2022 10:33:33 +0100 Subject: [PATCH] file permissions windows --- set-ssh-key-permissions.ps1 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 set-ssh-key-permissions.ps1 diff --git a/set-ssh-key-permissions.ps1 b/set-ssh-key-permissions.ps1 new file mode 100644 index 0000000..d65443c --- /dev/null +++ b/set-ssh-key-permissions.ps1 @@ -0,0 +1,22 @@ +# Set Key File Variable: + New-Variable -Name Key -Value "$env:UserProfile\.ssh\odroid_rsa" + +# Remove Inheritance: + Icacls $Key /c /t /Inheritance:d + +# Set Ownership to Owner: + # Key's within $env:UserProfile: + Icacls $Key /c /t /Grant ${env:UserName}:F + + # Key's outside of $env:UserProfile: + TakeOwn /F $Key + Icacls $Key /c /t /Grant:r ${env:UserName}:F + +# Remove All Users, except for Owner: + Icacls $Key /c /t /Remove:g Administrator "Authenticated Users" BUILTIN\Administrators BUILTIN Everyone System Users + +# Verify: + Icacls $Key + +# Remove Variable: + Remove-Variable -Name Key \ No newline at end of file