Skip to content

Instantly share code, notes, and snippets.

@tuyendq
Created June 13, 2020 11:21
Show Gist options
  • Save tuyendq/88f7f69d395eaee07d3a39c719b154cd to your computer and use it in GitHub Desktop.
Save tuyendq/88f7f69d395eaee07d3a39c719b154cd to your computer and use it in GitHub Desktop.
Set permission SSH Private Key File
:: Set key variable as full path the the private key id_rsa file ::
:: set key="%userprofile%\.ssh\id_rsa"
set keyname="ocifree"
set key=%~dp0%\%keyname%
:: Remove default inheritance ::
cmd /c icacls %key% /c /t /inheritance:d
:: Set ownership to the owner ::
cmd /c icacls %key% /c /t /grant %username%:F
:: Remove All users, except the owner ::
cmd /c icacls %key% /c /t /remove Administrator Administrators SYSTEM "Authenticated Users" "Users" AzureAD\TuyenDang
:: Then verify settings ::
cmd /c icacls %key%
:: End of script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment