Permission Denied
troubleshootingSSH is opinionated about file permissions. If permissions are wrong, SSH silently refuses to use the key—no error message in normal mode, just "Permission denied." This is the single most common cause of "my key doesn't work" problems.
Why SSH cares: if a private key file is readable by other users, it might already be compromised. SSH would rather fail than use a key it can't trust. The same applies to authorized_keys on the server—if the file or its parent directories are writable by others, SSH ignores it entirely.
Fix all permissions at once, locally:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
chmod 644 ~/.ssh/*.pub
chmod 644 ~/.ssh/known_hosts
And on the server:
chmod 755 ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
The home directory matters. Even if ~/.ssh and authorized_keys are correct, the server rejects the key if your home directory is group- or world-writable. Server-side sshd requirement, and it trips people up constantly.
When key auth fails silently, the diagnosis path is:
- Verbose output:
ssh -vvv user@server—look for lines containing "Permissions", "ignored", or "bad ownership". - Server-side logs (requires existing access):
sudo tail -20 /var/log/auth.logorsudo journalctl -u sshd -n 20. The server logs exactly why it rejected the key. - Ownership:
ls -la ~/.ssh/—everything should be owned by your user. Root-owned files in~/.sshare a common artifact of runningssh-keygenwithsudo.
Common patterns:
| Symptom | Likely cause | Fix |
|---|---|---|
| "Permission denied (publickey)" | Private key is 644 instead of 600 | chmod 600 ~/.ssh/id_* |
| Works locally, not from new machine | Forgot permissions after copying | Run the fix-all commands |
| Works as root, not as user | authorized_keys owned by root |
chown user:user ~/.ssh/authorized_keys |
| Suddenly stops working | Home directory permissions changed | chmod 755 ~/ on the server |
| Works on one server, not another | Different sshd strictness (StrictModes) |
Check server-side /etc/ssh/sshd_config |