SSH to AWS EC2: ‘permissions 0644 are too open’ error

To connect to an EC2 instance over SSH, if the permissions on your .pem file are too broad then you’ll see this error:

Permissions 0644 for ‘keypair.pem’ are too open.

It is required that your private key files are NOT accessible by others.

This private key will be ignored.

chmod the .pem file to 0400 and then you should be good. This is described here.

3 Replies to “SSH to AWS EC2: ‘permissions 0644 are too open’ error”

  1. The chmod 400 does not solve the issue in my case.

    D:\6 AWS\AWS Certified Developer – Associate (June 2018)
    λ ls -la
    -rw-r–r– 1 Arend 197121 1692 Jul 20 10:25 MyNewKeyPair.pem

    λ chmod 400 MyNewKeyPair.pem

    D:\6 AWS\AWS Certified Developer – Associate (June 2018)
    λ ls -la
    -r–r–r– 1 Arend 197121 1692 Jul 20 10:25 MyNewKeyPair.pem

    λ ssh ec2-user@35.157.189.183 -i MyNewKeyPair.pem
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions for ‘MyNewKeyPair.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 “MyNewKeyPair.pem”: bad permissions
    ec2-user@35.157.189.183: Permission denied (publickey).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.