29

I just created an Ubuntu instance on EC2, but when I try and SSH into the machine, I get:

UNPROTECTED PRIVATE KEY FILE!  
permissions 0644 for 'xxxxx.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: xxxxx.pem
Permission denied (publickey).

In creating the key, you only enter a name (without the option of adding a password).

How can I SSH into the machine without this warning popping up?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Emile
  • 3,464
  • 8
  • 46
  • 77

1 Answers1

80

Private keys must be readable only by the owner ..

Do chmod 400 xxxxx.pem on the machine from which you're connecting

scibuff
  • 13,377
  • 2
  • 27
  • 30
  • 2
    I've tried several solutions, and this one works like a charm. – Rafael Motta Mar 18 '13 at 13:14
  • 1
    When I first downloaded the file I got the OPs error. When I chmod to 400 or 600 I get 'Permission denied (publickey). – DrHall Feb 21 '14 at 01:52
  • 1
    @DrHall make sure you're connecting as the ec2-user: `ssh -i /path/to/key.pem ec2-user@xxxxxx.amazonaws.com` – Lukas S. Mar 17 '16 at 02:29
  • @arun Use Linux Command line tool. In Ubuntu version of EC2, we need to use ubuntu@ip instead of ec2-user@ip – oscarz Sep 18 '18 at 19:55