Fixed: Cannot SSH in Windows to AWS: UNPROTECTED PRIVATE KEY FILE Error. Permissions for private key are too open. This private key will be ignored.
1 min readFeb 13, 2022
When I tried to SSH from a Windows machine to a Linux EC2 Instance in AWS, I got a Permissions for private key are too open error.
The Error:
ssh -i "kopicloud-dev-linux.pem" admin@ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
The authenticity of host 'ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com (xx.xxx.xxx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:17indCVlLkDT0s87jTqVqmnoCJ0STal8rSMqkGdamk8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com,xx.xxx.xxx.xxx' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'kopicloud-dev-linux.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 "kopicloud-dev-linux.pem": bad permissions
admin@ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com: Permission denied (publickey).
The Solution:
Open the Command Prompt and type:
Icacls "kopicloud-dev-linux.pem" /Inheritance:r
Icacls "kopicloud-dev-linux.pem" /Grant:r "%Username%":"(R)"
And that’s all, folks. If you liked this story, please show your support by 👏 this story. Thank you for reading!