PortScan › Port guide › Port 22

Port 22 (SSH): Is It Safe to Leave Open? Secure Configuration

TCP 22SSHRemote accessExposure risk: Medium

Port 22 is SSH remote access. Essential for server admin, but password logins make it a brute-force target. Practical hardening: key auth, no root login, IP limits.

What is port 22?

SSH (Secure Shell) is the standard way to open an encrypted terminal session on a remote server. Linux servers, cloud VMs and the admin interfaces of many routers and NAS devices all run SSH on port 22. The connection itself is strongly encrypted, so unlike FTP or Telnet, simply "being open" is not dangerous in itself.

The problem is authentication. An internet-facing port 22 receives thousands of automated login attempts a day. If password login is enabled and the password is weak, it is only a matter of time.

When it is normally open

Risks if it is open

Constant brute forcing

Open port 22 on a fresh VPS and within minutes Failed password for root starts piling up in /var/log/auth.log. Attack bots cycle through common usernames such as root, admin, ubuntu and pi, combined with leaked password lists.

Vulnerabilities in OpenSSH itself

Rare, but they happen. regreSSHion (CVE-2024-6387), disclosed in 2024, allowed pre-authentication remote code execution in OpenSSH 8.5p1 through 9.7p1 on glibc-based Linux. SSH is a service where security updates should never wait.

Leaked private keys

Even with key authentication, a private key file leaked from a laptop or CI server lets an attacker walk straight in. Protect private keys with a passphrase.

Security checklist

How to check whether port 22 is open

From outside (is it exposed to the internet?)

Whether your server or home router accepts port 22 from the internet can only be confirmed by connecting from outside. A check from inside the same network bypasses the router's firewall and gives a different answer.

PortScan opens a real TCP connection from the Cloudflare edge and reports Open, Closed or Filtered. Members can scan every port on their own IP for free and other targets free once a day.

Check port 22

On the server (what is listening?)

Windows (PowerShell):

netstat -ano | findstr ":22 "
Get-NetTCPConnection -LocalPort 22 -State Listen | Select LocalAddress,OwningProcess

Linux:

sudo ss -tlnp | grep ':22 '

If it listens on 0.0.0.0 or [::] it is open on every network; 127.0.0.1 means only that machine can connect. To test port 22 on a server from another computer, use Test-NetConnection server-address -Port 22 on Windows or nc -vz server-address 22 on Linux and macOS.

How to close or restrict port 22

The best fix is to turn the service off or make it listen only on 127.0.0.1 (see the checklist above). If you need the service but must keep it off the internet, use a firewall.

Windows Firewall

# Administrator PowerShell
New-NetFirewallRule -DisplayName "Block TCP 22" -Direction Inbound -Protocol TCP -LocalPort 22 -Action Block
# To allow a single IP instead (block rules take precedence, so use this instead of the rule above)
New-NetFirewallRule -DisplayName "Allow TCP 22 from office" -Direction Inbound -Protocol TCP -LocalPort 22 -RemoteAddress 203.0.113.10 -Action Allow

Linux (ufw)

sudo ufw deny 22/tcp
# Allow a single IP only
sudo ufw allow from 203.0.113.10 to any port 22 proto tcp

On a cloud server, also check port 22 in the security group (inbound rules), which is separate from the OS firewall. For services running in Docker, the rules Docker creates can bypass ufw, so binding the port to localhost with -p 127.0.0.1:22:22 is the reliable option.

Router

At home or in a small office, open the router's admin page and check whether port 22 is in the port forwarding list, whether DMZ is enabled, and whether any program opened ports by itself through UPnP. If any of the three applies, port 22 on your PC is directly visible from the internet.

How to read the scan result

The verdict can depend on where you connect from. Many ISPs (including most Korean ISPs) block some ports such as 135, 139 and 445 on their network, so the same server can look Filtered from inside that network and Closed from abroad.

FAQ

Port 22 is open. Is that dangerous?
If only key authentication is allowed and OpenSSH is up to date, you are generally fine. If password login is enabled, change that right away.
The scan banner shows a string like SSH-2.0-OpenSSH_8.9p1
That is the version string the server sends right after you connect. Attackers see it too, so check whether that version has known vulnerabilities and update.
21 FTP23 Telnet3389 RDP (Remote Desktop)

Last updated 2026-11-04 · Use this guide to check systems you manage. Scanning systems without permission may carry legal liability.