SSH "Permission Denied (publickey)": Fixed for Good

Symptom

Server refuses login with publickey error.

Root cause

The key is wrong, unreadable by sshd, or not in authorized_keys.

Fix, in order

1. Debug in real timessh -v user@host 2>&1 | grep -i "offer\|denied"
2. Fix permissions (the classic)chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
3. Verify the right key is offeredssh -i ~/.ssh/<key> user@host
4. Check the server side logtail -20 /var/log/auth.log

Prevent it coming back

Use ssh-agent and one key per device; keep root login off.

Deep-dive article

Full walkthrough: SSH "Permission Denied (publickey)": Fixed for Good on the NinjaOps blog.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

Managed cloud hosting

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps 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