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.
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 -vvvoutput you seeOffering public key, thenAuthentications that can continue: publickey,keyboard-interactive, then the failure.
The usual causes, most common first:
- The server does not have your public key
authorized_keysis 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 ignoresauthorized_keysif the home directory,~/.sshor 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
AllowUsersorAllowGroups.AuthenticationMethods publickey,keyboard-interactiverequires 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 noin 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
The error text alone cannot tell you whether the key or the password step failed. The verbose log can.
- Run SSH with maximum verbosity and read which keys are offered and which methods the server says can continue.
ssh -vvv user@host - In another terminal, list the keys loaded in your agent.
ssh-add -l - 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
If the agent is empty or holds several keys, the correct one may never be offered.
- Connect with the key named explicitly.
ssh -i ~/.ssh/KEY user@host - Or start the agent and load the key.
eval "$(ssh-agent -s)" ssh-add ~/.ssh/KEY
3.For GitHub and similar services, test with the service user
These services reject any user other than the one they define, and they match your key by fingerprint.
- Run the test command and read the output.
ssh -vT [email protected] - 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
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).
- The simplest way is
ssh-copy-id, which appends your key.ssh-copy-id user@host - To do it by hand, on the server create the directory and file.
mkdir -p ~/.ssh touch ~/.ssh/authorized_keys - Paste the whole public key into
authorized_keysas a single line.
5.Fix ownership and permissions on the server
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.
- Inspect the home directory,
~/.sshand the key file.ls -ld ~ ~/.ssh ls -l ~/.ssh/authorized_keys - 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
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.
- Open the server configuration (and any files under
sshd_config.d) and checkPubkeyAuthentication yes,AuthorizedKeysFile,AuthenticationMethods,AllowUsers,AllowGroupsandKbdInteractiveAuthentication. In current OpenSSHChallengeResponseAuthenticationis a deprecated alias of the latter. Both default toyes. - If
AuthenticationMethodslistspublickey,keyboard-interactive, the server requires both a valid key and a successful second step. Make sure both work. - After changing a setting, restart the service. The unit may be called
sshon some distributions.systemctl restart sshd
Check that it worked
ssh user@hostconnects without the Permission denied message.ssh -vvv user@hostshows your key being accepted rather than a list of methods that can continue.
If it still fails
- Re-read the
ssh -vvvoutput 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
- sshd_config(5) manualOfficial · OpenBSD
- Error: Permission denied (publickey)Official · GitHub Docs
- Troubleshoot SSH Key Authentication Issues · Akamai (Linode)