FreshScanSentry Free vulnerability scanning for your network & web apps Run a free scan

Low risk Port 22 · SSH

SSH port 22 is open: is it a risk, and how to secure it

Short answer: port 22 is SSH, the standard way to log in to Linux servers, NAS boxes and network gear remotely. On a server you manage over the internet, having it open is normal. What makes it risky is how it's set up: password logins, root allowed to log in, or an outdated OpenSSH.

The fix: allow key-based logins only, turn off root login, keep OpenSSH updated, and limit who can reach the port. If nobody uses SSH on that machine, close it.

What is port 22?

SSH (Secure Shell) gives an administrator a command line on a remote machine, encrypted end to end. Web hosts, cloud servers (AWS, Azure, DigitalOcean and others) and most Linux systems have it on by default. It also shows up on NAS devices, routers and firewalls, sometimes switched on without anyone remembering.

Unlike Telnet or FTP, SSH encrypts everything, so the finding is not about eavesdropping. It's about who can try to log in, and how hard that is.

Why it still matters

How it looks in your report your-server
  1. 22 SSH Normal, but should be key-based and rate-limited Low
If the scan detects an outdated OpenSSH, that is reported separately

How to check your SSH setup

  1. See what's answering. A FreshScanSentry Basic Scan shows port 22 and the SSH version. Or, from a machine outside your network:
    nmap -p 22 -sV your-server
  2. Check whether passwords are accepted:
    nmap -p 22 --script ssh-auth-methods your-server
    If the result lists password or keyboard-interactive, password logins are allowed. Only publickey means keys only, which is what you want.
  3. Check the version. On the server, run ssh -V. Then check your distribution's security notices: Ubuntu and Debian often fix vulnerabilities without changing the version number. The outdated OpenSSH guide explains how.

Only scan servers you own or have written permission to test.

How to secure it

Keep your current SSH session open while you make these changes, and test a new login from a second window before closing it. That way a mistake can't lock you out.

1. Switch to key-based logins

On your own computer, create a key and copy it to the server:

ssh-keygen -t ed25519
ssh-copy-id you@your-server

Log in again to confirm the key works without asking for your account password.

2. Turn off passwords and root login

Edit /etc/ssh/sshd_config (or add a file in /etc/ssh/sshd_config.d/):

PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
MaxAuthTries 3

Check the file for mistakes, then reload SSH:

sudo sshd -t
sudo systemctl reload ssh      # Ubuntu and Debian
sudo systemctl reload sshd     # RHEL, Fedora, Rocky, AlmaLinux

On Windows Server with OpenSSH, the same settings go in C:\ProgramData\ssh\sshd_config; restart the OpenSSH SSH Server service afterwards.

3. Slow down password guessing with fail2ban

fail2ban blocks addresses that fail to log in repeatedly. On Ubuntu and Debian:

sudo apt install fail2ban

The SSH protection is on by default there. With key-only logins the guesses can't succeed anyway, but fail2ban keeps the logs readable and cuts the load.

4. Limit who can reach port 22

5. Close it where nobody uses it

On a NAS, router or camera, turn SSH off in the device's settings unless someone actually needs it. On a router, also remove any port forwarding rule for 22.

6. Keep OpenSSH updated

Install security updates regularly (sudo apt update && sudo apt upgrade on Ubuntu and Debian), or turn on automatic security updates. Then re-scan to confirm.

What doesn't work on its own

If you think someone already got in

Check the login log: /var/log/auth.log on Ubuntu and Debian, or journalctl -u ssh (-u sshd on RHEL). Look for Accepted password or Accepted publickey lines from addresses you don't recognise. Also look for unknown keys in each user's ~/.ssh/authorized_keys and unexpected new user accounts. If you find any, take the machine off the network and get incident response help before cleaning up, so evidence isn't lost.

Common questions

Is port 22 open a vulnerability?

Not by itself. It's an exposed service, which is why FreshScanSentry rates it Low. It becomes a real problem when passwords are accepted, root can log in, or OpenSSH is out of date.

The scan says port 22 is "tcpwrapped".

Something accepted the connection but didn't answer like SSH. It's often a cloud firewall or load balancer. Check your firewall rules and whether anything is actually listening on the server.

Our hosting company manages the server.

Ask them whether SSH allows passwords and root login, and whether it can be limited to your IP address. Many hosts offer this in their control panel.

Sources: OpenSSH sshd_config manual · OpenSSH 9.8 release notes (CVE-2024-6387) · NVD: CVE-2024-6387 · Nmap ssh-auth-methods · fail2ban