[Solve] Public key error on CentOS 6

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

If you have suddenly started getting public key error while login via ssh , it means either your authorized_keys permission’s are wrong or either your sshd_config as changed.

If you never disabled password authentication and enabled key authentication , later is the problem.

Solution

To do that, open the file using the commands below.

vi /etc/ssh/sshd_config

Then comment and change the lines to match the ones below.
Make sure these lines are commented, meaning they have the (#) before it.

# PubkeyAuthentication yes
# AuthorizedKeyFile    .ssh/authorized_keys
# PasswordAuthentication no
# ChallengeResponseAuthentication no

Save the file and reload SSH server by running the commands below.

service sshd reload

This will disable key authentication on your server.