Server refuses login with publickey error.
The key is wrong, unreadable by sshd, or not in authorized_keys.
ssh -v user@host 2>&1 | grep -i "offer\|denied"chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keysssh -i ~/.ssh/<key> user@hosttail -20 /var/log/auth.logUse ssh-agent and one key per device; keep root login off.
Full walkthrough: SSH "Permission Denied (publickey)": Fixed for Good on the NinjaOps blog.
Spinning up a fresh box to reproduce or escape this error?
Managed cloud hostingNinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.
Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog