SSH is a very useful protocol for when you need to remotely access a computer and are comfortable with typing around in a terminal. That said, having a secure SSH connection to your remote host is very important as it prevents from anyone connecting to said host and compromising system security.
In this article, we’re talking about the “permission denied publickey gssapi keyex gssapi with mic” error, its causes and what you can do to fix the problem.
Also read: How to fix error 60029: PermissionDenied?
What causes the Permission denied publickey gssapi keyex gssapi with mic error?
The error can be caused by a number of different reasons including but not limited to:
- Incorrect SSH configuration
- The authorised_keys file has insufficient permissions
- Incorrect SSH key

Also read: Fix: Error: Failed to build gem native extension
How to fix Permission denied publickey gssapi keyex gssapi with mic error?
Here are two fixes you can try out.
Enable password authentication
One way of fixing the error is to simply enable password authentication on your remote host. All you have to do is edit the sshd_config file found in / etc / ssh and change the following flags.
- PasswordAuthentication: change this to yes.
- ChallengeResponseAuthentication: change this to no.
You can access the file using nano using this command.
sudo nano / etc /ssh / sshd_config

Change file permissions
If enabling password authentication didn’t work, try playing around with file permissions.
Step 1: Open the sshd_config file using the following command.
sudo nano / etc /ssh / sshd_config
Step 2: Change the following options.
- PermitRootLogin: change to no
- PubkeyAuthentication: change to yes
Step 3: Comment the following options by adding a ‘#’ before the option.
- GSSAPIAuthentication
- GSSAPICleanupCredentials
Step 4: Save the file and restart the sshd service.
systemctl restart sshd
Step 5: Finally, run the following commands to change file permissions on the required files.
chmod 0700 /home/[username]
chmod 0700 /home/[home directory]/.ssh
chmod 0600 /home/[username]/.ssh/authorized_keys
Also read: Fix: Error: Attempt to use zero-length variable name