Last active
June 29, 2022 14:57
-
-
Save SolomonHD/d8b68218c353541c57210bca6cda29d3 to your computer and use it in GitHub Desktop.
Powershell Change SSH Key Perms
This file contains hidden or 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
## This Powershell template sets proper perms for ssh key usage in WSL2. Edit the variables before running | |
## Requires Powershell 7+!!! | |
## Set Variables | |
New-Variable -Force -Name Key -Value "$env:UserProfile\.ssh\key_file_name_here" | |
New-Variable -Name PERMS -Value "RW" | |
## Perform Operations, | |
Icacls $Key /c /t /Inheritance:d && Icacls $Key /c /t /Grant ${env:UserName}:$PERMS && TakeOwn /F $Key && Icacls $Key /c /t /Grant:r ${env:UserName}:$PERMS | |
Icacls $Key /c /t /Remove:g Administrator "Authenticated Users" BUILTIN\Administrators BUILTIN Everyone System Users | |
## Optional Cleanup | |
Remove-Variable -Name Key | |
Remove-Variable -Name PERMS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment