What Uses Port 22
Port 22 is the standard TCP port for SSH. On a Linux server the program behind it is the OpenSSH server, sshd. Several tools share the one port because they all run over SSH:
- Remote login: a shell on the server with
ssh user@your_.server_ ip - File transfer: SFTP and scp.
- Tunnels and Git: port forwarding, and Git remotes that use SSH.
Logging in for the first time is covered in how to SSH into a server.
See What Listens on Port 22
sudo ss -ltnp 'sport = :22'You should see sshd. On Ubuntu 24.04 and later the process may show as systemd, because Ubuntu starts SSH through a systemd socket that holds the port and starts sshd on the first connection. Check the service with systemctl status ssh on Ubuntu and Debian, or systemctl status sshd on AlmaLinux and Rocky Linux.
Check It Is Open from Outside
From your own computer, against your own server:
ssh -v user@your_server_ip
nc -zv your_server_ip 22With -v, ssh prints each step; a line saying the connection was established shows the port is reachable, even if the login fails later. nc only reports whether the TCP port opens; see the nc command.
Limit SSH to Your Own Address
If you always connect from a fixed address, allow SSH only from there. Work in this order, or you can lock yourself out: add the new rule first, keep your current session open, log in from the allowed address in a second terminal, and only then remove the open rule. Have the server console in your provider's control panel at hand. With UFW on Ubuntu and Debian:
sudo ufw allow from 203.0.113.10 to any port 22 proto tcp
sudo ufw status numberedAfter the test login works, delete the general rule. It is sudo ufw delete allow 22/tcp, or sudo ufw delete allow OpenSSH if it was added by profile name. Then open one more new login from the allowed address before you close the first session. With firewalld on AlmaLinux and Rocky Linux:
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" service name="ssh" accept'
sudo firewall-cmd --reloadTest the new login, then remove the open service and test once more in a new terminal:
sudo firewall-cmd --permanent --remove-service=ssh
sudo firewall-cmd --reloadIf your address changes often, skip this step: a home connection that gets a new address would lock you out. Rely on keys and Fail2ban instead.
Block Repeated Failures with Fail2ban
Port 22 on any public server receives login attempts from bots all day. Fail2ban reads the SSH log and blocks addresses that fail too often. It keeps the noise down but does not replace key login; see how to install Fail2ban. The measures that matter most are key-only login and no direct root login, described in how to disable SSH password authentication.
Changing the Port
Moving SSH to another port reduces log noise; it is not a security measure by itself. The safe order, the SELinux step on AlmaLinux and Rocky Linux, and the Ubuntu socket detail are in how to change the SSH port.
Connection Refused on Port 22
- Connection refused: the packets reached the server, but nothing listens on that port or a firewall rejects them. sshd may be stopped or listening on another port; check with ss from the console.
- Connection timed out: a firewall drops the packets, or the address is wrong.
- Permission denied: the port works; the problem is the key, the user, or the login settings.
Detailed checks are in SSH connection refused and SSH connection timed out.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations