How to set 600 permission on a .pem file in w10?

I am unable to change permissions to 600 on an AWS .pem file.

  • Note that "inherited permissions" were turned off in all efforts, and owner was set properly.
  1. Tried using this guide with File Explorer:
  2. Tried using this guide with PowerShell as Admin, and ICACLS:
    Windows SSH: Permissions for 'private-key' are too open
  3. Tried good ole' fashioned:
    chmod 600 with Git Bash. ng.
  4. I followed the instructions in this vid (skip to 5:17):
  5. I've also tried resetting the file in an Admin Windows Powershell with:

icacls .\key.pem /T/ Q/ /C /RESET

The file stubbornly remains at permissions 644, or rw-r--r--. Since AWS requires 600 on a .pem file, this prevents me from ssh'ing into my instance.

Nothing is working! Why is this stuck? Why can't I change these permissions? Such a simple thing hanging me up and eating up time... frustrating. Ty.

2 Answers

I got in. For posterity, here's what was happening. It was a two-part problem.

  1. I am using Git Bash. On an ls -al command, the permissions were shown as rw-r--r--. When viewed in Windows Properties, they were set correctly.

  2. The username on the remote box was not properly set up for ssh

To discover this, I logged in using tried from my Mac, setting the permissions in a linux-style. There I found that the username was not set up. Then I went back to windows and tried again, despite the permissions appearing wrong in Git bash... and it worked.

1

The answer of Chao helped me, because I have WSL installed on my Windows 10.

In WSL (Ubuntu on Windows) I opened a text editor with sudo and created the file /etc/wsl.conf with text in it:

[automount]
options = "metadata"

Then rebooted my Windows.

Now I am able to edit file permissions in WSL: chmod 0600 now works!

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like