πŸ“– ~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 access is denied after enabling UFW, potentially locking out administrators.

Environment & Reproduction

Ubuntu 18.04 hosts where ufw enable was run before SSH allow rules were added.

Root Cause Analysis

Default deny incoming policy blocks TCP/22, or rule order and interface scoping are incorrect.

Quick Triage

From console access, run sudo ufw status numbered and confirm current inbound policy and SSH rules.

Step-by-Step Diagnosis

Check whether OpenSSH listens on non-standard port and verify corresponding UFW rule exists on the active interface.

Illustrative mockup for ubuntu-18-04-lts β€” ubuntu1804-ufw-ssh-blocked-diagnose.webp
Reviewing UFW rules and active firewall state β€” Illustrative mockup β€” Progressive Robot

Solution – Primary Fix

Add allow rule first (sudo ufw allow OpenSSH or allow /tcp), then reload UFW and confirm remote connectivity.

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

Illustrative mockup for ubuntu-18-04-lts β€” ubuntu1804-ufw-ssh-blocked-fix.webp
Allowing SSH safely with proper UFW rule ordering β€” Illustrative mockup β€” Progressive Robot

Solution – Alternative Approaches

Temporarily disable UFW from console in emergency scenarios, then reconfigure rules with staged testing.

Verification & Acceptance Criteria

Remote SSH succeeds, ufw status shows explicit allow, and other inbound traffic remains restricted.

Rollback Plan

Delete new numbered rules and restore previously exported UFW ruleset if required.

Prevention & Hardening

Use scripted firewall rollouts that always whitelist management access before enabling deny policies.

Connection timed out on SSH, denied packets in kernel logs, and accidental host lockout incidents.

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

View all Ubuntu 18.04 LTS tutorials on the Tutorials Hub β†’

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

man ufw, Ubuntu UFW docs, and OpenSSH server hardening guides.

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.