If you are doing SSH into a newly created EC2 Instance, and if you are a newbie like me, you can get following error:
Only tricky part is that the userid can depend on the AMI you are using. For example, if you use Amazon Linux AMI, the user id is "ec2-user", and if you use "Ubuntu AMI", the user id is "ubuntu".
One way to find out probably will be to trying to use "root@server-name", and then you will get an error like this, which will make it clear as to which user id one should use.
To resolve it, you need to use userid@server-name in the SSH Command.srikanth@ubuntu:~/AWS$ ssh -i Home-Ubuntu.pem ec2-user@ec2-174-129-93-173.compute-1.amazonaws.com
Permission denied (publickey).
Only tricky part is that the userid can depend on the AMI you are using. For example, if you use Amazon Linux AMI, the user id is "ec2-user", and if you use "Ubuntu AMI", the user id is "ubuntu".
One way to find out probably will be to trying to use "root@server-name", and then you will get an error like this, which will make it clear as to which user id one should use.
srikanth@ubuntu:~/AWS$ ssh -i Home-Ubuntu.pem root@ec2-174-129-93-173.compute-1.amazonaws.com
Please login as the user "ubuntu" rather than the user "root".

