Affected versions: Ubuntu 22.04 LTS

📖 ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

SSH key login fails and administrators risk lockout.

Environment & Reproduction

Ubuntu 22.04 server with recent edits to ~/.ssh or /etc/ssh/sshd_config.

Root Cause Analysis

OpenSSH enforces strict ownership and permission checks on key files and home paths.

Quick Triage

Inspect auth log with journalctl -u ssh and run sshd -t for config validation.

Step-by-Step Diagnosis

Check permissions on home directory, .ssh directory, and authorized_keys file.

Illustrative mockup for ubuntu-22-04-lts — ssh_permissions_diag
OpenSSH rejects key authentication because file modes are too open — Illustrative mockup — Progressive Robot

Solution – Primary Fix

Set chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys with correct user ownership.

Still having issues? Our IT Consulting team can diagnose and resolve this for you. Get in touch for a free consultation.

Illustrative mockup for ubuntu-22-04-lts — ssh_permissions_fixed
Correct file ownership and modes restore SSH key login — Illustrative mockup — Progressive Robot

Solution – Alternative Approaches

Temporarily allow password authentication from trusted subnet while repairing key setup.

Verification & Acceptance Criteria

SSH key auth succeeds and sshd -t returns clean configuration output.

Rollback Plan

Revert sshd_config changes and restart ssh service from console session.

Prevention & Hardening

Use configuration management to enforce known-good SSH permissions and options.

PAM misconfiguration and fail2ban bans can present similar login failures.

Related tutorial: View the step-by-step tutorial for Ubuntu 22.04 LTS.

View all Ubuntu 22.04 LTS tutorials on the Tutorials Hub →

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

Ubuntu 22.04 OpenSSH server hardening and troubleshooting 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.