CH-J Toolsserver management over SSH
Menu
All guides and articles →

Server is online but SSH port 22 is not responding

Work through the client, network, firewall and sshd in order to find why the server answers but SSH does not.

What does an unresponsive port 22 actually mean?

A server can answer ping and serve a website while SSH is unavailable. Ping normally uses ICMP, HTTPS usually uses TCP port 443, and SSH normally uses TCP port 22. Each can have different listeners, firewall rules and network paths. A working website might also belong to a proxy rather than the machine you need to administer.

Separate the stages before changing anything. The client resolves an address, establishes TCP, receives an SSH identification string, negotiates encryption and authenticates the user. Record the exact error, destination address, port, source network and time of one attempt so you can compare it with server logs.

  • Connection refused: an endpoint or firewall actively rejected the connection. A missing listener is common, but this does not prove sshd is stopped.
  • Connection timed out: the connection did not complete within the limit. Filtering, routing, a wrong address or resource exhaustion are possible causes.
  • Permission denied: SSH reached authentication. Investigate the account or credentials rather than opening more firewall ports.

How do you test the correct destination from the client?

Run these commands from the affected client. The nc example uses OpenBSD netcat, packaged as netcat-openbsd on Ubuntu/Debian; other implementations have different options. OpenSSH verbose output shows the attempted address and stage. All example names and IP addresses in this guide are documentation placeholders; replace them with actual values.

nc -vz -w 5 server.example 22
ssh -vv -o ConnectTimeout=5 -p 22 user@server.example
ssh -G server.example

Inspect hostname, port, proxyjump and proxycommand in ssh -G output. An alias can select another machine or route through a bastion; a direct nc probe does not follow that SSH configuration. Confirm the endpoint against your inventory or provider console. If the documented SSH port is 2222, test it with ssh -p 2222 instead of assuming 22 should be open.

ssh -4 -v -o ConnectTimeout=5 user@server.example
ssh -6 -v -o ConnectTimeout=5 user@server.example

Test each address family where the hostname has the corresponding DNS record and your client has connectivity. IPv4 success with IPv6 failure narrows the investigation to the IPv6 path, listener or filtering. On a Windows client, use this PowerShell TCP test and inspect RemoteAddress and TcpTestSucceeded rather than the ping result.

Test-NetConnection -ComputerName server.example -Port 22 -InformationLevel Detailed

Is SSH listening on the Linux server?

Use the provider, hypervisor or physical console. On Ubuntu/Debian with systemd, inspect ssh.service and, where installed, ssh.socket. Some Ubuntu installations use socket activation, so systemd can own the listener while the SSH service is idle. A missing socket unit alone is not a fault. On RHEL derivatives the service is normally sshd.service.

sudo systemctl status ssh.service ssh.socket --no-pager
sudo ss -lntp
sudo /usr/sbin/sshd -t
sudo /usr/sbin/sshd -T | grep -E "^(port|listenaddress|addressfamily) "
sudo journalctl -u ssh.service -u ssh.socket -n 50 --no-pager

Read the local address and port in ss output. A listener on 127.0.0.1 accepts local IPv4 connections only; one bound to an obsolete interface address cannot serve the new address. Check /etc/ssh/sshd_config and its included files, commonly under /etc/ssh/sshd_config.d. The configuration printed by sshd -T describes a new daemon invocation, not necessarily the live socket or an already running process.

For RHEL, substitute sshd.service in the status and journal commands. If the server package is absent, establish whether SSH was intended to be installed before adding it. Resolve syntax errors, missing host keys and address conflicts from the reported error rather than repeatedly restarting.

Where is a timed-out connection being lost?

Map the path: client or corporate outbound filter, VPN, router/NAT, provider firewall or security group, then host firewall. A private server may require a VPN or jump host. With NAT, verify that the public TCP port forwards to the correct internal address and SSH port. Check both directions; replies can leave through a different gateway.

Inspect the firewall manager actually in use. UFW applies only where installed; nft lists nftables rules, not every possible filtering mechanism. With tcpdump installed, capture one short connection test at the Linux console, then stop with Ctrl+C. Adjust the filter for a different SSH port.

sudo ufw status verbose
sudo nft list ruleset
sudo tcpdump -ni any -nn "tcp port 22"
  • No matching packets: verify the destination and capture scope, then inspect upstream routing and filters. An empty capture does not identify a particular blocking firewall.
  • Incoming SYN without an observed reply: inspect local filtering, the listener and return routing. Capture visibility and packet processing order limit the conclusions.
  • Repeated SYN and SYN-ACK without the final ACK: investigate the return path and client filtering. A completed handshake moves the investigation to SSH itself.

How do you repair the confirmed Linux cause safely?

Keep console access and any working SSH session open. Listener and firewall changes can lock you out. Before editing, back up the configuration file you will change, including any relevant included file.

  1. Correct only the identified cause: restore the intended Port or ListenAddress, fix the reported syntax error, or repair the specific network rule.
  2. Run /usr/sbin/sshd -t with sudo and proceed only after success. For a stopped Ubuntu/Debian service without socket activation, the command below starts it after validation.
  3. For a running service, use its supported reload after validation. With socket activation, inspect systemctl cat ssh.socket and follow the installed distribution documentation for listener changes; reloading ssh.service alone may leave the socket unchanged.
  4. If an active UFW firewall lacks the intended permission, add a narrow rule for the actual client source address, then test a new connection.
sudo /usr/sbin/sshd -t && sudo systemctl start ssh.service

This UFW example is for an already active UFW setup and one administrator IPv4 address. Replace the source with the address seen by the server after NAT or VPN, and use the actual destination port. Inspect rule order first: an earlier deny can take precedence. Do not enable UFW incidentally or edit its rules through another firewall manager.

sudo ufw status numbered
sudo ufw allow from 198.51.100.25 to any port 22 proto tcp

If one source fails, inspect fail2ban when installed. Use sudo fail2ban-client status sshd only if that jail exists. Confirm the source and reason before unbanning an address; correct stale credentials or automation causing failures. Success from another network narrows the problem but does not prove a ban.

What should you check on Windows Server?

On Windows Server 2022 or 2025 with the built-in OpenSSH Server installed, use elevated PowerShell. Inspect the service, listener and standard inbound firewall rule. Configuration normally lives at C:\ProgramData\ssh\sshd_config. For a different OpenSSH installation, verify the service executable and use that installation path.

Get-Service sshd
Get-NetTCPConnection -State Listen -LocalPort 22
Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" | Format-List Name,Enabled,Direction,Action,Profile
Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" | Get-NetFirewallPortFilter
& "$env:WINDIR\System32\OpenSSH\sshd.exe" -t

A missing named rule does not prove all SSH traffic is blocked; inspect effective policy, address scope and the active network profile. Check Event Viewer under Applications and Services Logs, OpenSSH, Operational. After fixing and validating configuration, start a stopped service with Start-Service sshd. Applying configuration changes to a running Windows sshd requires Restart-Service sshd; keep console access and retest afterward.

Why does TCP connect while SSH still hangs?

A successful TCP probe proves only that something accepted the connection. If verbose SSH output stops before the remote identification string, verify that the listener belongs to the expected service. A proxy, socket activation failure, connection limits or an overloaded host can interrupt this stage.

uptime
free -h
df -h
df -i

These Linux checks show load, memory, filesystem capacity and inode use. Read them alongside the SSH journal and system errors; high load alone does not establish the cause. A full filesystem or exhausted memory can prevent new sessions while other services respond. Find what consumes resources before removing files or stopping workloads.

For connections dropped before authentication, check logs for MaxStartups limits rather than blindly increasing them. If authentication completes but the shell hangs, investigate account lookup, PAM where used, home directories and shell startup files. These are later stages than a closed port; changing firewall rules will not repair them.

How do you verify recovery, and what should you avoid?

Repeat the original test from the affected network using the same hostname and intended port. Confirm TCP, the SSH handshake, host identity and a fresh authenticated session. Test IPv4 and IPv6 where supported. A surviving old session or successful localhost test does not establish that new remote connections work.

  • Do not flush firewall rules or disable the firewall to make a test pass. Correct the specific rule and preserve intended source restrictions.
  • Do not enable root or password login to fix a TCP timeout. Authentication policy is evaluated after the connection reaches SSH.
  • Do not reinstall OpenSSH, delete host keys or reboot as the first response. Preserve evidence and identify the failing layer.

If the recovered connection presents an unexpected host key, stop and verify its fingerprint through the console or another trusted channel. Restoring reachability does not establish that you reached the intended server.

How do you prevent another SSH access outage?

Document the management hostname, port, address families, VPN or bastion requirement and firewall owner. Keep recovery console access usable before maintenance. Validate configuration before applying it, change one layer at a time and test a second session before closing the first. When moving ports, verify the new allowed path before removing the old one.

Monitor the management TCP endpoint from a network that should reach it, separately from website availability. Keep source allowlists aligned with administrator VPN or public address changes. Record the repair and observed failure stage so the next incident starts from a known baseline.

How does CH-J Tools help locate the failing stage?

Server Diagnostics in CH-J Tools can test ping, a TCP connection and the SSH identification string without logging in, for IPv4 and IPv6. These checks distinguish a responding machine from a reachable TCP service and an SSH service that sends its identification string.

The tests run from your computer only. They cannot inspect the server or identify which firewall dropped a packet. Use the result to choose the next console or network check in this guide; server-side diagnosis still requires console access when SSH is unavailable.

Frequently asked questions

Can ping work when port 22 is blocked?

Yes. ICMP and TCP are handled separately. Test the intended TCP port from the affected client; ping neither opens SSH nor proves that the hostname points to the intended SSH machine.

Does connection refused always mean sshd is down?

No. A missing listener is common, but a firewall can actively reject connections too. Compare the listener, firewall policy and packet capture for the exact destination address and port.

Why does SSH work from another network only?

Compare source addresses, VPN routes, outbound policy and DNS answers. A source allowlist or fail2ban ban is possible, but different destinations or IPv4/IPv6 paths can produce the same symptom.

Can I fix an SSH timeout by changing my SSH key?

Not when TCP cannot connect. User keys are used during authentication. First determine whether TCP connection, SSH negotiation or authentication fails, then investigate that layer.

Should I move SSH from port 22 to fix the outage?

Only if the intended configuration or a confirmed policy requires another port. Moving ports does not repair routing or a stopped daemon; the listener, firewall, NAT and client must agree.

Detailed documentation

OpenSSH: sshd →

man: ss →

OpenSSH: ssh →

OpenSSH: ssh_config →

OpenSSH: sshd_config →

Ubuntu Server: OpenSSH server →

Ubuntu Server: Firewall →

Microsoft Learn: OpenSSH Server configuration →

Biometric unlock and security →

All tutorials by category →