📖 ~1 min read
Table of contents
Symptom & Impact
Remote SSH sessions fail immediately after firewall updates. Administrators risk losing access to production hosts.
Environment & Reproduction
Ubuntu 22.04 servers using ufw default deny incoming policy. Reproduce by enabling ufw before allowing port 22/tcp.
Root Cause Analysis
Firewall policy blocks required management ports, often due to missing allow rules or interface-specific rule mismatches.
Quick Triage
Use console access, run sudo ufw status numbered, and confirm whether OpenSSH or custom SSH port is allowed.
Step-by-Step Diagnosis
Check active sshd port in /etc/ssh/sshd_config, verify ufw logs in journalctl, and test connectivity from a trusted source host.

Solution – Primary Fix
Allow SSH explicitly with sudo ufw allow OpenSSH or sudo ufw allow /tcp, then reload ufw and validate rule ordering.
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Solution – Alternative Approaches
Use cloud security groups plus host firewall in layered mode, or restrict SSH by source CIDR for reduced attack surface.
Verification & Acceptance Criteria
SSH login succeeds from approved networks, ufw status reflects expected policy, and no unintended ports are exposed.
Rollback Plan
Disable ufw temporarily via console if fully locked out, then restore previous rules from saved ufw user.rules backup.
Prevention & Hardening
Apply firewall changes in staged sessions, maintain out-of-band access, and automate rule validation checks.
Related Errors & Cross-Refs
Connection timed out on port 22, ufw denied packets, ssh unreachable after firewall enable.
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 ufw documentation, man ufw, OpenSSH hardening references.
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.