📖 ~1 min read
Table of contents
Symptom & Impact
SSH login fails with permission denied despite valid keypair.
Environment & Reproduction
Often occurs after home directory permission changes or sshd config edits.
ssh -vvv user@host
sudo systemctl status ssh --no-pager
Root Cause Analysis
Incorrect file permissions, wrong username, or sshd settings disable key auth.
Quick Triage
Check server logs for exact auth rejection reason.
sudo journalctl -u ssh -n 100 --no-pager
sudo sshd -T | grep -Ei 'pubkeyauthentication|authorizedkeysfile'
Step-by-Step Diagnosis
Validate key files and ownership on target account.
ls -ld ~/.ssh
ls -l ~/.ssh/authorized_keys
namei -l ~/.ssh/authorized_keys

Solution – Primary Fix
Restore canonical SSH permissions and ensure PubkeyAuthentication is enabled.
Still having issues? Our IT Consulting team can diagnose and resolve this for you. Get in touch for a free consultation.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown -R $USER:$USER ~/.ssh
sudo systemctl reload ssh

Solution – Alternative Approaches
Use Match blocks for specific users if global policy conflicts exist.
sudoedit /etc/ssh/sshd_config.d/99-local.conf
sudo sshd -t
sudo systemctl reload ssh
Verification & Acceptance Criteria
Key-based login succeeds without password fallback.
ssh -o PreferredAuthentications=publickey user@host 'id'
Rollback Plan
Restore previous sshd snippets if authentication behavior regresses.
sudo rm -f /etc/ssh/sshd_config.d/99-local.conf
sudo systemctl reload ssh
Prevention & Hardening
Manage sshd config in drop-in files and test with sshd -t before reload.
sudo sshd -t
Related Errors & Cross-Refs
Related messages include Authentication refused: bad ownership or modes.
Related tutorial: View the step-by-step tutorial for Ubuntu 24.04 LTS.
View all Ubuntu 24.04 LTS tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
OpenSSH and Ubuntu server hardening documentation.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.