π ~1 min read
Table of contents
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.

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.

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.
Related Errors & Cross-Refs
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.