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).