Affected versions: 24.04

📖 ~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

Remote SSH attempts fail with ‘Connection refused’.

Environment & Reproduction

Common on fresh server installs where OpenSSH server was not enabled.

Root Cause Analysis

sshd is stopped, missing, or blocked by firewall policy.

Quick Triage

Check sudo systemctl status ssh and sudo ss -tulpn | grep :22.

Step-by-Step Diagnosis

Validate config syntax with sudo sshd -t and inspect logs with journalctl -u ssh -n 50.

Solution – Primary Fix

Install and start service: sudo apt install -y openssh-server && sudo systemctl enable –now ssh && sudo ufw allow OpenSSH.

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 allow port 22 using sudo ufw allow 22/tcp if profile names are unavailable.

Verification & Acceptance Criteria

ssh user@host connects and key authentication succeeds.

Rollback Plan

Disable service with sudo systemctl disable –now ssh if emergency rollback is needed.

Prevention & Hardening

Use key-based login and disable password authentication after validation.

Related: ‘Connection timed out’ when network routing differs.

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 server hardening guides and Ubuntu server docs.

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.