What is port 22 used for?
Secure Shell for remote terminal access, file transfers (SFTP, SCP) and Git over SSH.
Should port 22 be open?
Open only if you need it. Expose it only when required, with encryption and strong authentication, ideally limited to known IP addresses. Port 22 is scanned constantly. Disable password logins, disable root login, and consider fail2ban or limiting access to known IPs. Moving SSH to another port reduces log noise but isn’t real security.
See what is listening on port 22
# Linux
sudo ss -tlnp | grep ':22 '
# macOS
sudo lsof -nP -i TCP:22 -sTCP:LISTEN
# Windows (PowerShell)
Get-NetTCPConnection -LocalPort 22 -State Listen
Open or block port 22 in a firewall
# Ubuntu / Debian (ufw)
sudo ufw allow 22/tcp
sudo ufw deny 22/tcp
# Windows (PowerShell, as administrator)
New-NetFirewallRule -DisplayName "Port 22" -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow
On cloud servers, also open the port in the provider’s security group or network firewall. At home, a service behind a router needs a port-forwarding rule to the device’s local IP.
Test it from outside
A port can be open on the server but blocked upstream. The Port Checker connects from the internet, so it shows what the world sees. From your own machine, use nc -vz example.com 22 (macOS/Linux) or Test-NetConnection example.com -Port 22 (Windows).