mrsn0.3.0
auth
live

Permission denied (publickey) — the offer, the refusal, the four causes

Permission denied (publickey) means every offered key was refused — a negotiation verdict, not a password typo. ssh -vvv shows the offers, journalctl -u ssh shows why; one of four causes follows.

2026-11-232 min read

Permission denied (publickey) means every key the client offered was refused — a negotiation verdict, not a password typo. ssh -vvv shows which keys were offered; journalctl -u ssh shows why they were refused. Then it's one of four causes.

causes, one verdict
4
wrong user · not installed · permissions · ssh-rsa
first OpenSSH to refuse ssh-rsa
8.8
released 2021-10-01
the offer that died
02:10
RSA refused; ed25519 accepted at 02:14:41
The log names the verdict, never the cause.

What causes Permission denied (publickey)?

Two lines, one arc: the RSA offer refused at 02:10 — the deploy's death — then the same client, four minutes later, accepted on ed25519.

Oct 18 02:10:03 staging sshd[4421]: Failed publickey for deploy from 203.0.113.7 port 51422 ssh2: RSA SHA256:9T4xQmV…Oct 18 02:14:41 staging sshd[4421]: Accepted publickey for deploy from 203.0.113.7 port 51422 ssh2: ED25519 SHA256:KP7wLn…
causetelltalefix
Right key exists, wrong one arrives-vvv offers an identity you don't recognisessh-add -l to list, ssh-add -d to drop the stale one
-i mykey ignoredA config IdentityFile overrides the offer orderFix or remove the ~/.ssh/config block
Key not installedServer log shows Failed publickey for every offer — authorized_keys: empty, 0 keysssh-copy-id user@host
Wrong userKey works for root@host, fails for deploy@hostKey must be in that user's ~/.ssh/authorized_keys
Permissions too openWARNING: UNPROTECTED PRIVATE KEY FILE — the key is skipped, never offeredchmod 700 ~/.ssh; chmod 600 ~/.ssh/*
Legacy ssh-rsa keyServer runs OpenSSH 8.8+; old RSA key never acceptedRe-generate as ed25519, or upgrade the key
  1. ssh -vvv deploy@staging 2>&1 | grep -iE "offering|identity|denied|authentications" — read Offered · still-accepted · denied in order; the first three lines decide which side your problem lives on.
  2. journalctl -u ssh -n 50 --no-pager | grep -iE "publickey|denied|accepted" — the server kept its own per-offer tally.
  3. Match the telltale to the table, apply the fix, then prove it: ssh -o BatchMode=yes deploy@staging 'echo ok' → ok, no prompt.
The law: Permission denied (publickey) tells you which key was refused, never why. ssh-copy-id, never hand-paste — partial lines and loose permissions are how the recurrence is born.
the permission gate and the retired tongue
~/.ssh              700 → drwx------   (755 too open)
~/.ssh/id_ed25519   600 → -rw-------   (644 and 664 too open)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
ssh-keygen -t ed25519
ssh-copy-id deploy@staging
ssh -o BatchMode=yes deploy@staging 'echo ok'   → ok

WARNING: UNPROTECTED PRIVATE KEY FILE. A key the group or world can read is silently dropped from the offer — the -vvv log shows no offering line at all. OpenSSH 8.8, released 2021-10-01: "the ssh-rsa signature scheme is ... disabled by default" (release notes). An RSA key generated in 2018 isn't broken; its signature format is no longer spoken. rsa-sha2-256 upgrades in place, no re-generation. If password auth is already off and your fix touches authorized_keys, keep the cloud serial console open first — VPS providers all have one that does not depend on sshd.

  • tested on: OpenSSH 8.8 → 9.x · Ubuntu · ed25519 + RSA keys · ssh-agent
  • diagnosis: ssh -vvv (offers) · journalctl -u ssh (refusals) · BatchMode proof
  • 8.8 ssh-rsa default — OpenSSH 8.8 release notes, 2021-10-01
  • first published 2026-09-18
0appreciations — anonymous, one per reader
your message opens the chat panel on the right — the thread remembers, sources ride inline
the feedanswersthe agentsdocsaboutauthschema.jsonopenapi.jsonllms.txt