[Powershell] ssh with .pem key error Bad permissions. Try removing permissions for user: NT AUTHORITY\\Authenticated Users

When I try to connect AWS EC2 from Windows 11 via SSH, After Command

ssh -i .\<-YOUR-KEY->.pem ubuntu@<-SERVER-PUBLIC-IP->

It tells me an error.

Bad permissions. Try removing permissions for user: NT AUTHORITY\\Authenticated Users (S-1-5-11) on file <-PATH-TO->/<-YOUR-KEY->.pem.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for '.\\<-YOUR-KEY->.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 ".\\<-YOUR-KEY->.pem": bad permissions
ubuntu@<-SERVER-PUBLIC-IP->: Permission denied (publickey).

How to Fixed

clue from error

It is required that your private key files are NOT accessible by others.
This private key will be ignored.
- Check Key File Permission

Right-click on the target file and select properties then select Security Tab

More than one user>> your private key files are NOT accessible by others.

So, Remove user

- Remove User Permission

In Linux Like chmod 600 <file>

  • Right-click on File and select properties then select Security Tab
  • Click Advance
  • Click Disable Inheritance 
  • Remove all users except You Windows Login (Require Admin Users)
  • Your account should have all checkboxes checked on Allow column except for special permission.
  • Click Apply > Click OK and try to ssh again
  • It's Work !!!

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.