Skip to content

Instantly share code, notes, and snippets.

@ericchansen
Created May 24, 2023 19:36
Show Gist options
  • Save ericchansen/b56ca1565787522b8ded48da58d84b4d to your computer and use it in GitHub Desktop.
Save ericchansen/b56ca1565787522b8ded48da58d84b4d to your computer and use it in GitHub Desktop.
Fix permission issues in Windows for id_rsa.
New-Variable -Name Key -Value "$env:UserProfile\.ssh\id_rsa"
Icacls $Key /c /t /Inheritance:d # Disable inheritance of permissions from parent objects.
Icacls $Key /c /t /Grant ${env:UserName}:F # Grants full control (F) permission to current user.
TakeOwn /F $Key # Take ownership.
Icacls $Key /c /t /Grant:r ${env:UserName}:F # Grants full control (F), but replace any existing permissions rather than add them.
Icacls $Key /c /t /Remove:g Administrator "Authenticated Users" BUILTIN\Administrators BUILTIN Everyone System Users # Remove these groups from the access control list.
Icacls $Key # Display updated permissions.
Remove-Variable -Name Key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment