I\'ve just setup my EC2 server following this video here exactly - http://www.youtube.com/watch?v=bBajLxeKqoY
I even chose the same server type, everything went well
Just do
sudo su -
Worked for me
For me, the issue was that I had created an AMI from an existing instance, so when I launched the AMI, even though I selected a new key, the instance's original key was what worked.
chmod 400 pem_file
ssh -i /path_to_the_pem_file ec2-user@ServerIP
or
ssh -i /path_to_the_pem_file ubuntu@ServerIP
root access is prohibited by default by AWS AMIs.
hope it helps.
This is the way to connect:
ssh -i /path/my-key-pair.pem ec2-user@public-ip
Now, instead of ec2-user, it could be root, or centos, or ubuntu, or something else. You can check under the "Usage Instructions". If it's not there, and you've tried all the above users, find out from the documentation that came with the AMI.
There is one bug on AWS that cost me a lot of time. If you're launching an instance from a saved AMI under "Images > AMIs", note that it uses the original keys of the running instance it was created from. When launching the AMI, it will prompt you to choose a new key, and even show such key under the description, but the truth is those keys will never work!
So if you're using a custom/saved AMI you'll have to either get the original keys and use them, or just create a brand new one from AWS or the market place. If you haven't created the AMI or can't remember where it came from, look under the details tab. You can then launch a new instance or create a new AMI from the same source. This will then use the keys that you specify.
You will be asked for password when you enable PasswordAuthentication yes
in your sshd_config. Try changing that to no. that should fix it.
Just for anyone else that might have the same problem
Updating this answer because of the activity:
Depending on if the system is ubuntu or Rhel the user varies.
For ubuntu it is
ssh -i my-pem-file.pem ubuntu@my-ec2-instance-address
For RHEL it is
ssh -i my-pem-file.pem root@my-ec2-instance-address
Connecting to an ec2 instance does not require a password, it would require only a pem file and this is how you connect to it
ssh -i my-pem-file.pem ec2-user@my-instance-address
and remember to chmod 400
your pem file before ssh'ing