MySQL Access denied for publickey

You’ll probably need to generate key pairs and users in ec2 when using it as a jump server for your AWS RDS in order to connect to your MySQL databases. Despite the fact that we occasionally build private key (PEM) files and public keys are added to the ec2 user’s “.ssh/authorized keys,” you may occasionally encounter connection failure errors in Navicat or Workbench.

The error is-
Access denied for ‘publickey’.
Authentication that can continue:publickey,gssapi-keyex,gssapi-with-mic

This error is mostly because of permissions/security context issues. In order to solve this, you will need to run the below command.

chmod 700 .ssh
chmod 600 .ssh/authorized_keys
restorecon -r -vv .ssh/authorized_keys

The restorecon command is used to set the security context (extended attributes) on one or more files.

Make sure to create the keypair (.pem) file’s authorized key (public key) on a Mac or Linux system. Try to avoid generating the public key using Windows ssh keygen.

Additionally, make sure that .ssh (chmod 700) and .ssh/authroized keys have the appropriate permissions (chmod 600).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s