Port 22: SSH

Port 22 (TCP) is used by SSH. Secure Shell for remote login, plus SFTP and SCP file transfer and port forwarding. The most scanned port on the internet after 80/443.

22Port
TCPProtocol
sshIANA service name
Remote accessCategory

Port range

22 is a well-known (system) port (range 0–1023). On Linux and macOS, binding to it traditionally needs root or the CAP_NET_BIND_SERVICE capability.

Security

Only open port 22 to the hosts that need it. Prefer the encrypted variant of the protocol where one exists.

Open port 22 in a firewall

ufw         sudo ufw allow 22/tcp
iptables    sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
firewalld   sudo firewall-cmd --permanent --add-port=22/tcp
Windows     New-NetFirewallRule -DisplayName "SSH 22" -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow

Check if port 22 is open

nc -vz example.com 22
Test-NetConnection example.com -Port 22   # PowerShell
sudo ss -tulpn | grep ':22 '   # what is listening locally (Linux)

Other remote access ports

Frequently asked questions

What is port 22 used for?
SSH. Secure Shell for remote login, plus SFTP and SCP file transfer and port forwarding. The most scanned port on the internet after 80/443.
Is port 22 TCP or UDP?
TCP.