Skip to content

Instantly share code, notes, and snippets.

@nemchik
Last active May 25, 2023 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemchik/375461d06a6f27d401918fc1269162e1 to your computer and use it in GitHub Desktop.
Save nemchik/375461d06a6f27d401918fc1269162e1 to your computer and use it in GitHub Desktop.
SSH Key permissions
# From: https://superuser.com/a/1329702
# Set Key File Variable:
New-Variable -Name Key -Value "$env:UserProfile\.ssh\id_ed25519"
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment