Windows: How to Do chmod 400?

Beverly Wang
3 min readJan 4, 2022

I recently switched from macOS to Windows 10 for some projects when using AWS, and of course, met some small but uncomfortable issues. The first one is chmod 400 on the .pem file. It is quite straightforward to do so in macOS (just key in chmod 400 “yourpemfile.pem” in the terminal is enough). However, there is no chmod command in Windows. There are two ways to do so:

  • Use GUI
  • Use PowerShell

Use Windows GUI

This is the most straightforward way.

Step 1: Go to the folder of the pem file and right-click the pem file to select “properties”. In the pop-up window, select the “Security” tab, and then click “Advanced” at the bottom.

Step 2: In the pop-up window, disable inheritance at the bottom first.

Step 3: Ensure that you are the owner and the only one who has full control of the file. If you are not the owner of the file, you can change it by clicking the button. If you know your username, key it in the blank and press OK directly.

Otherwise, click “Advance” and then search to find your username to add it.

Use PowerShell

Step 1: Open a folder, type “PowerShell” and then press Enter

It will pop up the PowerShell window as below.

Step 2: Run the command below. The first one is to reset pem file properties, the second one grants read-only access to the file, and the third one is to inherit the right.

icacls.exe “mypemfile.pem” /reset
icacls.exe “mypemfile.pem” /grant:r “$($env:username):(r)”
icacls.exe “mypemfile.pem” /inheritance:r

Reference

https://www.youtube.com/watch?v=P1erVo5X3Bs&ab_channel=LinuxAcademy

--

--