Error Fix

How to Fix 'Permission denied (publickey)' in SSH

The common causes of SSH key authentication failures and how to narrow them down.

This error means the server did not accept any of the keys your SSH client offered. The issue is usually the wrong key, missing authorized_keys entry, agent configuration, or server-side permissions.

Best Fixes

Verify which key your client is using and whether that public key exists on the target server or Git host.

Check file permissions, ssh-agent state, and host-specific SSH config entries.

Avoid This

Do not generate more keys blindly before confirming which key the server expects.

Do not ignore verbose SSH output when it can tell you exactly which keys were attempted.

Save commands, add notes, and build a Cheatbook with the fixes you want to keep handy.