permission denied (publickey-gssapi-keyex-gssapi-with-mic) – The issue of error SSH permission denied appears after permission related setting has been modified on the central SSH server. In most cases, it includes a new package installation or asked about creating new users.

In this blog, you will learn how to troubleshoot the SSH permission denied error and reconnect to your SSH server. And we will be telling you about what is causing Permission Denied (publickey,gssapi-keyex,gssapi-with-mic) and steps to fix the error of permission Denied (publickey,gssapi-keyex,gssapi-with-mic).

Reasons Causing SSH Permission Denied (publickey,gssapi-keyex,gssapi-with-mic)?

Reasons Causing SSH Permission Denied (publickey,gssapi-keyex,gssapi-with-mic)?

The permission denied error appears when trying to SSH into a server:

The authentication method that were tried but were unsuccessful at the time the connection was establish are listed in the bracket after the permission denied the statement. The error gives a false impression that the public key is the problem.

SSH server configuration file sshd config might be a contributing factor in the error. The system cannot read from the file as a result, and the permission denied error is returned. The authorized keys file may also not have enough licenses, which is another issue. The list of private keys for clients who are permitted to SSH onto the server is contained in this file.

How to Fix SSH Permission Denied Error

How to Fix SSH Permission Denied Error

The mentioned below are two solutions, and both contain the steps you need to perform on the primary server side. Begin with opening the terminal on your server and proceed with one of the given solution methodologies.

Solution 1: Enable Password Authentication

  • To resolve the permission denied error, activate password login in the sshd config file if you want to use a password to access the SSH server.
  • Now Open the file in a text editor to accomplish this. This illustration employs the nano editor.
  • Ensure the Password Authentication line in the file has a yes at the end.
  • Locate the ChallengeResponseAuthentication option, and then add on to make it inactive.
  • Remove the hash symbol # to uncomment lines that have been commented out.
  • Please save the file, then shut it down.
  • By entering the following command, the SSH service can be restarted.

Solution 2: Change File System Permissions

Utilizing the secret key-based login as the SSH validation strategy isn’t prescribed because of safety concerns. Accordingly, the accompanying arrangement might be ideal since it investigates the public essential confirmation technique.

In the first place, open the sshd_config document utilizing a word processor:

  • Sudo nano/and so on/ssh/sshd_config

In document, ensure the accompanying choices are set as follows:

  • PermitRootLogin no
  • PubkeyAuthentication yes

Remark out the GSSAPI-related choices by adding the hash sign toward the start of the line:

  • #GSSAPIAuthentication yes
  • #GSSAPICleanupCredentials no

Likewise, ensure the UsePAM line is set to yes:

  • UsePAM yes

Save the record and restart the sshd administration

Presently explore your home envelope and take a look at the consent:

  • If your proprietor consents are not set to peruse, compose, and execute (drwx- – – – – – ), utilize the chmod order to transform them:
  • chmod 0700/home/[your-username]

Presently go to the .ssh organizer and review the consent:

  • ls – ld

This catalogue should likewise have perused, composed, and executed authorizations for the document proprietor. To authorize them, use chmod once more:

  • chmod 0700/home/your_home/.ssh

The .ssh organizer contains the authorized_keys document. Take a look at its consent with the following:

  • ls – ld authorized_keys

The document proprietor ought to have perused and compose consents. To set them, use the following:

  • chmod 0600/home/[username]/.ssh/authorized_keys

Presently have a go at signing in with the critical pair once more. The result underneath shows an effective login endeavours.

Am I Using My SSH Keys Correctly?

Am I Using My SSH Keys Correctly?

The name itself makes it clear about the keypair error corrections. Moreover, follow the steps to make sure to consider SSH keys:

  1. You should never divulge your private key to anyone and, ideally, keep it encrypted with a passphrase.
  2. You can publish the public key anywhere in plain text and distribute it to everyone.
  3. The distant server has to see your public key to verify you have the right key, but your local environment should never see your private key.
  4. The private key can used to create the public key.
  5. While authenticating, your ssh client will present a public key to the distant server (which it will derive from the local private key).
  6. The server will check that the public key can authenticate to it before presenting a challenge that you can only resolve.

Can I Connect SSH with Remote Server’s Private Key?

A public key that does not need to kept secret and a private key are both used in SSH certificate authentication (PKI). Your private key is safely stored on client during PKI connection setup, and your corresponding public key is added to server. You can specify the public/private key pair ssh should use (either on the command line with ssh -I identity file> or in the configuration file for each host block) if you have numerous public/private key pairs.

As a convenience, AWS likely produces the public/private key for a login to the new instance. You save the private key locally after downloading it through a secure connection. The public key is already present, so from now on, the combination of each place that you want to treat.

How does ssh-copy-id get the public key when only the private key is loaded?

How does ssh-copy-id get the public key when only the private key is loaded?

This is genuinely report in the manual page on late frameworks. Note that there are a few distinct variants of the content; Curve Linux and RHEL/CentOS appear to have a similar form as Debian/Ubuntu, yet FreeBSD has various choices.

Naturally, the ssh-duplicate id calls ssh-add – L to list the keys that you have enrolled in the SSH specialist. Ssh-add – L results from a rundown of public keys for which you have the confidential key in the specialist. You could consider how the specialist can do this since you don’t pass it a public key by the same token.

The response is that it’s dependably conceivable to recreate the public key from the confidential key (this is valid for all the cryptosystems that SSH upholds and most that it doesn’t). This is valid for the “numerical” part of the key, nonetheless. The critical public record can likewise contain a remark (which you can set with ssh-keygen – C), and the specialist doesn’t stack this remark, so if you use an ssh-duplicate id. It takes a key utilizing the specialist, and the remote host will not have this remark in authorized_keys.

If there is no running specialist or it has no key, late Linux ssh-duplicate id search for (directly from the man page).

The latest record that matches: ~/.ssh/id*.pub (barring those that match ~/.ssh/*, so on the off chance that you make a key that isn’t the one you need ssh-duplicate id to utilize, use touch(1) on your favored key’s .bar document to reestablish it as the latest.

More established forms of the content and non-Linux adaptations don’t have this latest record conduct. To the extent that I recall, considerably more seasoned papers didn’t test the specialist and just read the default way ~/.ssh/ as a matter of course.


In the above article, our website Just Buffer has discussed all the steps needed to resolve the SSH Permission denied (publickey, gssapi-keyex, gssapi-with-mic) error covered in this blog. You should be able to correct the problem and successfully SSH onto your server by following the instructions in the guide.