“Connection refused” and “Operation timed out” look like the same SSH failure from the client side, but they point at opposite causes. Refused means a host answered and actively rejected you — sshd is not listening on that port, or a firewall is sending a reset. Timed out means nothing answered at all — packets are being dropped silently, almost always by a firewall DROP rule or because your own IP got banned. Reading which one you got is the first and most useful diagnostic step.
What’s happening
On a cPanel/WHM server, SSH access depends on a short chain: your packets reach the server’s public IP, the firewall (usually CSF/LFD) decides whether to allow or drop them, and if allowed they reach sshd listening on a port — 22 by default, but commonly moved. Any link can break the connection, and the error you see tells you which link.
A refused connection means the TCP stack answered with a reset. That happens when sshd is stopped or crashed, when it is listening on a different port than the one you tried, or when CSF is configured to REJECT rather than DROP. A timeout means your SYN packet was dropped with no reply — the classic signature of a firewall DROP, an LFD ban of your IP after failed logins, an upstream network ACL, or sshd bound to the wrong interface. A third case looks like a timeout but is really cPHulk: cPHulk protects WHM and SSH logins, and a One-Day Block there can refuse you even when the firewall would allow the packet.
Because a lockout can wall you out of the very server you need to fix, the recovery path almost always runs through an out-of-band channel: the provider’s serial console, a VNC/KVM session, or a rescue mode.
How to verify
From your workstation, first establish which failure you have and whether the port is even open:
# Verbose handshake — shows refused vs. timeout vs. auth
ssh -vvv -p 22 root@server.example.com
# Is the SSH port reachable at all from outside?
nc -vz server.example.com 22
nmap -Pn -p 22 server.example.com
If you reach the box another way (provider console, a second IP, an existing session), check the server side. Confirm sshd is up and which port it actually uses:
# Is sshd running, and on what port?
systemctl status sshd
ss -tlnp | grep sshd
grep -Ei '^port|^listenaddress' /etc/ssh/sshd_config
Then check whether the firewall or LFD has banned your source IP. Replace 203.0.113.10 with the address you are connecting from:
# Is my IP denied or temp-blocked by CSF/LFD?
csf -g 203.0.113.10
grep 203.0.113.10 /etc/csf/csf.deny
grep 203.0.113.10 /var/log/lfd.log | tail -20
Finally, rule out cPHulk, which blocks independently of the firewall:
# Is cPHulk holding a block on my IP?
whmapi1 read_cphulk_records list_name=brutes | grep -i 203.0.113.10
/usr/local/cpanel/scripts/restartsrv_cphulkd --status
A line in csf.deny or an lfd.log entry naming your IP explains a timeout. An ss output showing sshd on 2222 while you dialed 22 explains a refusal. No sshd process at all explains a refusal with the service simply down.
The fix
- Get an out-of-band session first — if you are fully locked out, do not keep retrying SSH; each attempt can deepen an LFD ban. Open the provider’s serial/KVM console or boot a rescue environment so you have a shell that does not depend on sshd or the firewall.
- Unban your own IP in CSF — a timeout plus a
csf.denyhit means LFD banned you (often after a few failed logins). Clear it withcsf -dr 203.0.113.10to remove the deny, thencsf -a 203.0.113.10to allow-list the address so it cannot be re-banned mid-session. Edit/etc/csf/csf.allowfor a permanent operator entry. - Clear a cPHulk block — if cPHulk is the culprit, run
whmapi1 flush_cphulk_login_history_for_ips ip=203.0.113.10, or whitelist the IP under WHM » cPHulk Brute Force Protection » Whitelist Management. cPHulk and CSF are separate gates; releasing one does nothing for the other. - Start or fix sshd — a refusal with no sshd process means the daemon is down.
systemctl start sshd(or/usr/local/cpanel/scripts/restartsrv_sshd). If it refuses to start, runsshd -tto validate the config — a syntax error after a recent edit is the usual reason it will not come back up. - Connect on the correct port — if
sshd_configshowsPort 2222(a common hardening step) but you dialed22, you get a refusal. Reconnect with-p 2222, and make sure that port is opened in CSF »TCP_INso the firewall does not drop it. - Reconcile the firewall rule type — if you want failed connections to time out (quietly drop) rather than announce the port with a reset, confirm
DROP = "DROP"in/etc/csf/csf.conf. Either way, ensure the SSH port is present inTCP_INand reload withcsf -r. - Check sshd is bound to the right interface — if
ListenAddresswas set to an internal or wrong IP, sshd will not answer on the public address and you get a timeout. Set it back to0.0.0.0(or the correct public IP), thensystemctl restart sshd. - Look upstream when the server looks clean — if sshd is up, the firewall allows your IP, and you still time out, the drop may be upstream: a cloud security group, a network ACL, or the provider’s edge filter. Verify from a second external host; if that also fails, the block is outside the server.
Once you are back in, set an operator allow-list entry in /etc/csf/csf.allow and a cPHulk whitelist for your management IPs so a few fat-fingered passwords never wall you out again. Stack Harbor keeps SSH and firewall access reliable under WHM server management — start a conversation if you are locked out of a server.