We may come across the ec2 key permission denied error due to different reasons.
It can occur if we try to connect using the wrong user name for the AMI. It can also happen if the permissions are incorrect on the instance.
Another scenario is an incorrect SSH public key (.pub) file in the authorized_keys file.
As part of our AWS Support Services, we assist our customers with several such errors.
Today, let us see how we can fix it.