EC2

AWS EC2 Error: Host key not found, Permission denied (publickey), or Authentication failed, permission denied

 

 

Host key not found, Permission denied

If you connect to your instance using SSH and get any of the following errors

  • Host key not found in [directory]
  • Permission denied (publickey)
  • Authentication failed, permission denied

possible reasons:

Check the keypair name in Description filed of your instance , and verify that you are using the correct private key file.

User name of AMI or .pem file may be wrong . verify that you are connecting with the appropriate user name for your AMI and that you have specified the proper private key (.pem) file for your instance.

  • For an Amazon Linux AMI, the user name is ec2-user.
  • For a RHEL AMI, the user name is ec2-user or root.
  • For an Ubuntu AMI, the user name is ubuntu or root.
  • For a Centos AMI, the user name is centos.
  • For a Debian AMI, the user name is admin or root.
  • For a Fedora AMI, the user name is ec2-user.
  • For a SUSE AMI, the user name is ec2-user or root.
  • Otherwise, if ec2-user and root don’t work, check with the AMI provider.

If you generated your own key pair, ensure that your key generator is set up to create RSA keys. DSA keys are not accepted

If you get a Permission denied (publickey) error and none of the above applies (for example, you were able to connect previously), the permissions on the home directory of your instance may have been changed. Permissions for /home/ec2-user/.ssh/authorized_keysmust be limited to the owner only

Stop the instance detach and attache the root volume into another running instance in temporary mount point ex /mnt

chmod 600 mount_point/home/ec2-user/.ssh/authorized_keys

chmod 700 mount_point/home/ec2-user/.ssh

chmod 700 mount_point/home/ec2-user

 

 

 

 

Tagged

1 thought on “AWS EC2 Error: Host key not found, Permission denied (publickey), or Authentication failed, permission denied

Leave a Reply

Your email address will not be published. Required fields are marked *