Skip to content
statance
MenuClose
← All ports

Port 2222: SSH (alternate port)

Medium risk

Port 2222 is most often an alternate SSH port, used to keep a second SSH server alongside the host’s, or to reduce log noise. DirectAdmin also uses 2222 for its control panel. It should not be reachable from the public internet.

Port
2222
Protocol
TCP
Service
SSH (alternate port)
Expose to internet?
No
Also used by
DirectAdmin, Docker containers running sshd, Gitea/Forgejo SSH

Is port 2222 safe to open?

Moving SSH to 2222 does not make it more secure, and scanners check this port too. If it is DirectAdmin, it is a full administration panel and should be protected like WHM. Check which process is listening before deciding.

How to secure SSH (alternate port)

  • Apply the same SSH hardening as on port 22: keys only, no root login.
  • For DirectAdmin, enable brute-force protection and restrict admin logins by IP.
  • Confirm what is listening with sudo ss -ltnp 'sport = :2222'.

Check if port 2222 is open

Linux: what is listening on this port

sudo ss -tlpn | grep ':2222 '

Windows (PowerShell): what is listening

Get-NetTCPConnection -LocalPort 2222 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}

From another machine: is it reachable

nc -zv HOST 2222 # or nmap -p 2222 HOST # Windows Test-NetConnection HOST -Port 2222

Test the SSH (alternate port) service itself

ssh -p 2222 -v -o BatchMode=yes USER@HOST exit

Restrict port 2222 in the firewall

Replace 10.0.0.0/8 with the network or address that needs access. Docker publishes container ports through its own iptables rules, which bypass ufw; bind published ports to 127.0.0.1 (-p 127.0.0.1:2222:2222) instead of relying on the host firewall.

ufw: allow only your private network, deny everyone else

sudo ufw allow from 10.0.0.0/8 to any port 2222 proto tcp sudo ufw deny 2222/tcp

firewalld: allow one source network only

sudo firewall-cmd --permanent --remove-port=2222/tcp sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="2222" protocol="tcp" accept' sudo firewall-cmd --reload

iptables

sudo iptables -A INPUT -p tcp --dport 2222 -s 10.0.0.0/8 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 2222 -j DROP

Windows Firewall (PowerShell, as Administrator)

New-NetFirewallRule -DisplayName "Block 2222 from internet" -Direction Inbound -Protocol TCP -LocalPort 2222 -RemoteAddress Internet -Action Block

Monitor port 2222

Run a TCP port monitor against your public IP on port 2222: here, a failed connection is the healthy result, so you know the firewall is still doing its job. On Linux, the Statance agent also reports every listening port on the server. TCP port monitoring.

Related ports

Port 22SSHMedium risk
Port 2087WHM (HTTPS)High risk

FAQ

What is port 2222 used for?

Port 2222 is most often an alternate SSH port, used to keep a second SSH server alongside the host’s, or to reduce log noise. DirectAdmin also uses 2222 for its control panel. It is also used by DirectAdmin, Docker containers running sshd, Gitea/Forgejo SSH.

Is it safe to open port 2222?

Not to the public internet. Moving SSH to 2222 does not make it more secure, and scanners check this port too. If it is DirectAdmin, it is a full administration panel and should be protected like WHM. Check which process is listening before deciding.

Is port 2222 TCP or UDP?

SSH (alternate port) uses TCP on port 2222.

How do I check if port 2222 is open?

On the server, run sudo ss -tulpn | grep ':2222 ' (Linux) or Get-NetTCPConnection -LocalPort 2222 (Windows) to see what is listening. From another machine, run nc -zv HOST 2222 or Test-NetConnection HOST -Port 2222.

All ports →

Know the moment a port stops answering.

TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.