This is probably a stupidly simple question to some :)
I\'ve created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me to
The issue for me was that my .pem file was in one of my NTFS partitions. I moved it to my linux partition (ext4).
Gave required permissions by running:
chmod 400 my_file.pem
And it worked.
You are likely using the wrong username to login:
ubuntu
ec2-user
root
or admin
To login, you need to adjust your ssh command:
ssh -l USERNAME_HERE -i .ssh/yourkey.pem public-ec2-host
HTH
SSH keys and file permission best practices:
public key/.pub file - 0600 (read & write only by owner)
chmod XXXX file/directory
Alternative log-in using PuTTY. Its good but needs a few steps.
Im using PuTTY 0.66 in Windows.
Change permission for the key file with :
chmod 400 key-file-name.pem
See AWS documentation for connecting to the instance:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html#EC2_ConnectToInstance_Linux
There can be three reasons behind this error.