How to fix Permission denied (publickey,keyboard-interactive). in SSH

SSHINTERMEDIATEMEDIUMUpdated May 28, 2026· 600 views

SSH fails with "Permission denied (publickey,keyboard-interactive)" when the server rejects both your public key and the interactive fallback. Usually missing/unauthorized keys, wrong permissions, or sshd config.

Quick fix

Fixes Permission denied (publickey,keyboard-interactive).

ssh -vvv username@remote-host
  1. Reproduce with verbose output first
  2. Verify your SSH key exists on the client
  3. Fix file permissions on the client
  4. Copy your public key to the server
ssh — error
ssh -vvv username@remote-host
Permission denied (publickey,keyboard-interactive).

What this error means

This error occurs when SSH tries public key authentication (the most secure method), the server rejects it, and then offers keyboard-interactive authentication (prompting for a password or challenge) as a fallback, which also fails. The methods listed in the parentheses are the ones the server was still willing to try when the connection was finally refused. Public key is the primary mechanism, and keyboard-interactive is a secondary fallback typically backed by PAM. If neither succeeds, the server closes the connection. The error is reported by the SSH client but the decision to reject is made by the server (sshd), so the root cause is almost always something about which keys you presented, their permissions on either side, or how sshd is configured.

Typical symptoms

  • SSH connection fails with 'Permission denied (publickey,keyboard-interactive)'
  • Cannot log into remote servers with your SSH keys
  • Password / keyboard-interactive prompt also fails or is never offered
  • Git/GitHub/GitLab operations over SSH fail to authenticate
  • Connection closes immediately after the error message
  • Verbose output (ssh -vvv) shows your key being offered but the server replying with another 'Authentications that can continue' list

Common causes

  1. The matching public key is not present in ~/.ssh/authorized_keys on the server
  2. File or directory permissions are too open on the client private key or on the server's ~/.ssh and authorized_keys
  3. The wrong SSH key is being offered (SSH tries default keys, not the one the server expects)
  4. Public key authentication is disabled in the server's sshd_config (PubkeyAuthentication no)
  5. The SSH agent is not running or does not have the right key loaded
  6. The private key is corrupted, in an unsupported format, or the wrong half of the pair
  7. Keyboard-interactive / password authentication is disabled on the server and no key was accepted
  8. The home directory or ~/.ssh on the server is group- or world-writable, causing sshd to ignore authorized_keys (StrictModes)
  9. The username or hostname in the SSH command is incorrect

How to fix "Permission denied (publickey,keyboard-interactive)."

1Reproduce with verbose output first

Before changing anything, run SSH in verbose mode to see exactly which keys are offered and where the server rejects them:

bash
ssh -vvv username@remote-host

Key lines to look for:
- Offering public key: / Will attempt key: — which keys the client is trying
- Authentications that can continue: publickey,keyboard-interactive — the methods the server still accepts
- Permission denied (publickey,keyboard-interactive). — the final rejection

If your key is never offered, the problem is client-side (missing key, agent, or IdentitiesOnly). If it is offered but rejected, the problem is server-side (authorized_keys content or permissions). This tells you which of the steps below to focus on.

2Verify your SSH key exists on the client

Check that you have an SSH key pair on your local machine:

bash
ls -la ~/.ssh/

You should see a private key and matching public key, e.g. id_ed25519 / id_ed25519.pub or id_rsa / id_rsa.pub. If you have none, generate a key (Ed25519 is preferred on modern systems):

bash
ssh-keygen -t ed25519 -C "you@example.com"

For maximum compatibility with very old servers, use RSA with a strong size:

bash
ssh-keygen -t rsa -b 4096 -C "you@example.com"

Use a passphrase when prompted; it protects the key at rest and can be cached by your agent so you are not prompted every time.

3Fix file permissions on the client

OpenSSH refuses to use a private key whose permissions are too open. Tighten them:

bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub

(Use the actual key filenames you found above.) Verify:

bash
ls -la ~/.ssh/

Expected:
- drwx------ (700) for the ~/.ssh directory
- -rw------- (600) for the private key
- -rw-r--r-- (644) for the .pub file

4Copy your public key to the server

Your public key must be listed in ~/.ssh/authorized_keys on the server for the account you are logging into. The simplest way (when you can still authenticate by another method, e.g. password) is:

bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub username@remote-host

If ssh-copy-id is unavailable, append the key manually. Note that ssh-copy-id and this command also create ~/.ssh and authorized_keys with correct permissions if missing:

bash
ssh username@remote-host "umask 077; mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" < ~/.ssh/id_ed25519.pub

Replace username and remote-host accordingly.

5Verify file permissions on the server

Log into the server (using any method that works) and ensure the SSH directory and authorized_keys are not too open. sshd's StrictModes will silently ignore authorized_keys if these are group- or world-writable:

bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

The home directory itself must also not be group- or world-writable. Check it and tighten only if needed:

bash
ls -ld ~
# if it is group/other writable, remove that write bit:
chmod go-w ~

Verify the results:

bash
ls -la ~/.ssh/

The ~/.ssh directory should be 700 and authorized_keys should be 600, owned by your user. Incorrect permissions here are one of the most common causes of this error.

6Confirm your public key is actually in authorized_keys

On the server, confirm the exact key you are using is present:

bash
cat ~/.ssh/authorized_keys

Each entry is a single long line starting with the key type (ssh-ed25519, ssh-rsa, ecdsa-sha2-...). A frequent mistake is a public key split across multiple lines by a copy/paste — each key must be exactly one line.

To confirm the key on the server matches your local key, compare fingerprints. On your client:

bash
ssh-keygen -lf ~/.ssh/id_ed25519.pub

On the server, run ssh-keygen -lf against the authorized_keys file; it prints one fingerprint per line, one for each authorized key:

bash
ssh-keygen -lf ~/.ssh/authorized_keys

Your client's fingerprint should appear in that list.

7Make sure the right key is being offered (IdentitiesOnly / SSH config)

If you have many keys, SSH may exhaust the server's MaxAuthTries by offering the wrong keys before reaching the correct one, producing this error even though a valid key exists. Force SSH to use only the key you specify:

bash
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 username@remote-host

Make it permanent in ~/.ssh/config:

bash
Host myserver
    HostName remote-host
    User username
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

Then connect with ssh myserver. IdentitiesOnly yes stops the client and agent from blindly offering every key.

8Check the SSH agent and loaded keys

If your key is never offered in the -vvv output, your agent may not have it loaded. Start the agent and list loaded keys:

bash
eval "$(ssh-agent -s)"
ssh-add -l

If the key is missing, add it (you will be prompted for the passphrase if it has one):

bash
ssh-add ~/.ssh/id_ed25519

On macOS, store the passphrase in the keychain so it loads automatically:

bash
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
9Check the SSH server configuration

If permissions and authorized_keys are correct but key auth is still rejected for everyone, inspect the server's sshd config. Edit /etc/ssh/sshd_config (and any drop-ins under /etc/ssh/sshd_config.d/):

bash
sudo nano /etc/ssh/sshd_config

Ensure these are present and not commented out:

bash
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
KbdInteractiveAuthentication yes

On older OpenSSH releases the keyboard-interactive directive is named ChallengeResponseAuthentication yes. Validate the config before applying it so a typo cannot lock you out:

bash
sudo sshd -t

If it reports no errors, reload sshd (keep your current session open until you confirm a new login works):

bash
sudo systemctl reload sshd

On systems without systemd:

bash
sudo service ssh reload

Advanced notes

Check the server auth logs. The server logs the real reason for the rejection, which the client cannot see. On the server: sudo tail -f /var/log/auth.log (Debian/Ubuntu) or sudo tail -f /var/log/secure (RHEL/CentOS/Fedora). Look for messages like "Authentication refused: bad ownership or modes" (a permissions/StrictModes problem) or "no matching key exchange/host key" (an algorithm mismatch, a different error class).

Legacy RSA (ssh-rsa) signatures. OpenSSH 8.8+ disables the old ssh-rsa (SHA-1) signature algorithm by default. An old RSA key can fail against a new server (or vice versa). The correct fix is to generate an Ed25519 key. As a temporary, scoped workaround you can re-enable it for one host with ssh -o PubkeyAcceptedAlgorithms=+ssh-rsa ..., but migrate the key rather than leaving this enabled.

SELinux / AppArmor. On enforcing systems these can block reading authorized_keys. Prefer restoring the correct SELinux context with restorecon -Rv ~/.ssh over disabling enforcement.

Restricted accounts. SFTP-only or chrooted accounts (via a Match block or a forced command) can present as auth failures or immediate disconnects. Check sshd_config for Match, ForceCommand, and ChrootDirectory.

SSH port. Confirm you are connecting to the correct port: ssh -p PORT username@host if sshd does not listen on 22.

Frequently asked questions

What does "Permission denied (publickey,keyboard-interactive)." mean?
This error occurs when SSH tries public key authentication (the most secure method), the server rejects it, and then offers keyboard-interactive authentication (prompting for a password or challenge) as a fallback, which also fails. The methods listed in the parentheses are the ones the server was still willing to try when the connection was finally refused. Public key is the primary mechanism, and keyboard-interactive is a secondary fallback typically backed by PAM.
How do I fix "Permission denied (publickey,keyboard-interactive)."?
SSH fails with "Permission denied (publickey,keyboard-interactive)" when the server rejects both your public key and the interactive fallback. Usually missing/unauthorized keys, wrong permissions, or sshd config.
What causes "Permission denied (publickey,keyboard-interactive)."?
The matching public key is not present in ~/.ssh/authorized_keys on the server File or directory permissions are too open on the client private key or on the server's ~/.ssh and authorized_keys The wrong SSH key is being offered (SSH tries default keys, not the one the server expects)
Is the "Permission denied (publickey,keyboard-interactive)." error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading