Skip to content

Instantly share code, notes, and snippets.

@harshithjv
Last active March 21, 2022 06:52
Show Gist options
  • Save harshithjv/3483f3566c5e42ab5ac8c70dd4a5ce4a to your computer and use it in GitHub Desktop.
Save harshithjv/3483f3566c5e42ab5ac8c70dd4a5ce4a to your computer and use it in GitHub Desktop.
Set private (read-only) permission for .pem file on Windows
REM Use icacls command in windows OS to set file permission which operates chmod in *nix platform. This script can be run on classic command prompt.
REM Syntax:
REM icacls.exe <ssh_Key_filename> /reset
REM icacls.exe <ssh_Key_filename> /grant:r "%username%":"(R)"
REM icacls.exe <ssh_Key_filename> /inheritance:r
icacls.exe vm_access.pem /reset
icacls.exe vm_access.pem /grant:r "%username%":"(R)"
icacls.exe vm_access.pem /inheritance:r
# Use icacls command in windows OS to set file permission which operates chmod in *nix platform. This script is meant for powershell execution.
# Syntax:
# icacls.exe <ssh_Key_filename> /reset
# icacls.exe <ssh_Key_filename> /grant:r "$($env:username):(r)"
# icacls.exe <ssh_Key_filename> /inheritance:r
icacls.exe vm_access.pem /reset
icacls.exe vm_access.pem /grant:r "$($env:username):(r)"
icacls.exe vm_access.pem /inheritance:r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment