Created
May 24, 2023 19:36
-
-
Save ericchansen/b56ca1565787522b8ded48da58d84b4d to your computer and use it in GitHub Desktop.
Fix permission issues in Windows for id_rsa.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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