Permission denied (publickey) when SSH Access to Amazon EC2 instance

This error occurs when you try to connect to an EC2 instance with ssh and the authentication failed. There are multiple reasons for this error to occur and in order to fix this error, you need to evaluate each of them. Here is a quick checklist for the possible cause of this error –

  1. Make sure you are using the correct SSH key to connect to the instance.
  2. Make sure the instance public dns name or public ip address is correct.
  3. Make sure the username is correct.

If you have checked all the above and still getting this error, try to connect with verbose enabled (-v option) with the ssh command to get additional details.

Leave a Reply