I'm using the new ssh client for windows 10 and when trying to connect with a private key I'm getting this error:

Permissions for 'MyPair.pem' are too open. It is required that your
private key files are NOT accessible by others. This private key will
be ignored. Load key "MyPair.pem": bad permissions ec2-user@
Permission denied (publickey).

I know that if I was on Linux I would need to run chmod 600 to set the file permissions, but what do you use on Windows 10?

  • icacls.exe or powershell Set-Acl or read this or this – LotPings Mar 30 at 20:22
up vote 5 down vote accepted

Keys must only be accessible to the user they're intended for and no other account, service, or group.

  • GUI:
    • [File] Properties - Security - Advanced
      1. Set Owner to the key's user
      2. Remove all users, groups, and services, except for the key's user, under Permission Entries
      3. Set key's user to Full Control

  • CLI:

    :: Set Variable ::
    set key="C:\Path\to\key"
    :: Remove Inheritance ::
    cmd /c icacls %key% /c /t /inheritance:d
    :: Set Ownership to Owner ::
    cmd /c icacls %key% /c /t /grant %username%:F
    :: Remove All Users, except for Owner ::
    cmd /c icacls %key%  /c /t /remove Administrator BUILTIN\Administrators BUILTIN Everyone System Users
    :: Verify ::
    cmd /c icacls %key%

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.