SSH "Permission denied (publickey,keyboard-interactive)": how to fix it

The server rejected every login method the client tried. The list in brackets only shows which methods it would still have accepted, here a key or a keyboard-interactive prompt. Run `ssh -vvv` to see which step failed, then fix the key, the username, or the permissions on the server.

Applies to:OpenSSH client and serverLinux, macOS, BSD
On this page

What it means

This is the familiar SSH "Permission denied (publickey)" failure with a longer list in brackets. The list is not a separate error. It names the authentication methods the server was still willing to accept when it turned you away. Here those are publickey and keyboard-interactive.

Keyboard-interactive is the challenge-response method. If you never got a prompt, or the prompt rejected what you typed, the login ends with this message. The message does not say which step went wrong, so the first job is to find out.

Other lists mean the same kind of failure with different server settings. A list that includes gssapi-keyex,gssapi-with-mic is covered in this related article. If you only see "please try again", see Permission denied, please try again.

Symptoms and causes

You are likely dealing with this problem if:

  • user@host: Permission denied (publickey,keyboard-interactive).
  • The login never asks for a password, or asks and rejects the one you typed.
  • In ssh -vvv output you see Offering public key, then Authentications that can continue: publickey,keyboard-interactive, then the failure.

The usual causes, most common first:

The server does not have your public key
authorized_keys is missing, empty, or does not contain the key you are using.
The client offers the wrong key, or none
The SSH agent is empty, you have several keys and the wrong one is tried first, or your key has a non-default filename.
Wrong username or host
Some services require a fixed user. GitHub, for example, requires git.
Ownership or permissions on the server are too open
With StrictModes yes (the default), sshd ignores authorized_keys if the home directory, ~/.ssh or the file has the wrong owner or is writable by others.
The password or keyboard-interactive step fails
A wrong password, a locked or expired account, PAM restrictions, or the user not being allowed by AllowUsers or AllowGroups. AuthenticationMethods publickey,keyboard-interactive requires both a key and a second step, so this message can appear even after the key was accepted.
Key authentication is disabled on the server
PubkeyAuthentication no in the server configuration.

How to fix it

Work through these in order. They start with the quickest, safest checks and move to deeper repairs; stop as soon as the problem is gone.

1.Find the failing step with verbose output

Easy

The error text alone cannot tell you whether the key or the password step failed. The verbose log can.

  1. Run SSH with maximum verbosity and read which keys are offered and which methods the server says can continue.
    Terminal
    ssh -vvv user@host
  2. In another terminal, list the keys loaded in your agent.
    Terminal
    ssh-add -l
  3. Check the username and hostname in the command. If the server is a service like GitHub, use the user it requires (git@).

2.Point SSH at the right key

Easy

If the agent is empty or holds several keys, the correct one may never be offered.

  1. Connect with the key named explicitly.
    Terminal
    ssh -i ~/.ssh/KEY user@host
  2. Or start the agent and load the key.
    Terminal
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/KEY

3.For GitHub and similar services, test with the service user

Easy

These services reject any user other than the one they define, and they match your key by fingerprint.

  1. Run the test command and read the output.
    Terminal
    ssh -vT [email protected]
  2. Compare the fingerprint of your key with the keys listed under Settings > SSH and GPG keys on GitHub. Add the key if it is missing.

4.Install your public key on the server

ModerateChanges settings

If authorized_keys lacks your key, no amount of client-side tweaking will help.

Before you start: You need some way to log in first (a password, or the provider's console).

  1. The simplest way is ssh-copy-id, which appends your key.
    Terminal
    ssh-copy-id user@host
  2. To do it by hand, on the server create the directory and file.
    Terminal
    mkdir -p ~/.ssh
    touch ~/.ssh/authorized_keys
  3. Paste the whole public key into authorized_keys as a single line.

5.Fix ownership and permissions on the server

ModerateChanges settings

With StrictModes yes (the default), sshd ignores the key file if ownership or modes are wrong.

Before you start: Change only the paths under the affected user's own home directory. Do not recursively change permissions on system directories.

  1. Inspect the home directory, ~/.ssh and the key file.
    Terminal
    ls -ld ~ ~/.ssh
    ls -l ~/.ssh/authorized_keys
  2. Make sure all three are owned by the login user, and that the home directory is not group-writable or world-writable.

6.Check the server configuration

AdvancedChanges settings

If the key is correct and permissions are fine, a server setting may be refusing the login, including the keyboard-interactive step.

Before you start: This needs console or administrator access.

  1. Open the server configuration (and any files under sshd_config.d) and check PubkeyAuthentication yes, AuthorizedKeysFile, AuthenticationMethods, AllowUsers, AllowGroups and KbdInteractiveAuthentication. In current OpenSSH ChallengeResponseAuthentication is a deprecated alias of the latter. Both default to yes.
  2. If AuthenticationMethods lists publickey,keyboard-interactive, the server requires both a valid key and a successful second step. Make sure both work.
  3. After changing a setting, restart the service. The unit may be called ssh on some distributions.
    Terminalneeds sudo / root
    systemctl restart sshd

Check that it worked

  • ssh user@host connects without the Permission denied message.
  • ssh -vvv user@host shows your key being accepted rather than a list of methods that can continue.

If it still fails

  • Re-read the ssh -vvv output line by line: note whether your key was offered and whether a password prompt appeared.
  • Ask the server administrator or hosting provider to look into why the server refused the login, since the client output does not say which step failed.
  • If it is a hosted service such as GitHub, follow the service's own SSH troubleshooting page.

Questions

What does keyboard-interactive mean in this message?

It is the challenge-response method. It is listed because the server would still accept it, not because it was the cause of the failure.

Sources

  1. sshd_config(5) manualOfficial · OpenBSD
  2. Error: Permission denied (publickey)Official · GitHub Docs
  3. Troubleshoot SSH Key Authentication Issues · Akamai (Linode)