Port 22 (SSH)

What port 22 is used for, which tools rely on it, and how to diagnose refused or timed-out SSH connections.

Updated

Port 22 is the default port for SSH, the Secure Shell protocol, and it uses TCP. SSH provides encrypted remote login and command execution, and it also carries file transfers (SFTP and SCP), port forwarding and Git operations over SSH. If you administer servers, this is the port you connect to most.

At a glance

Port 22
Service SSH (Secure Shell)
Transport TCP
Also carried over SSH SFTP, SCP, port forwarding, Git over SSH

What uses it

  • Remote shells. ssh user@host opens a terminal session on another machine.
  • File transfer. SFTP and SCP both run inside an SSH connection, so they use port 22 as well. SFTP is not the same thing as FTPS, which is FTP over TLS and uses different ports.
  • Tunnels. SSH can forward local or remote ports through its encrypted connection.
  • Git. Remotes written as git@host:owner/repo.git connect over SSH.

How a connection is secured

The server proves its identity with a host key. The first time you connect, your client asks you to confirm that key's fingerprint and then stores it. If the key later changes, the client warns you, because that can mean the server was rebuilt or that someone is intercepting the connection. The user then authenticates, most often with a key pair or a password.

Troubleshooting

  • Connection refused. The host is reachable but nothing is listening on port 22. The SSH service may be stopped, or it may be configured to listen on a different port.
  • Connection timed out. Packets are being dropped, usually by a firewall, a cloud security group or a routing problem. Confirm the address and that port 22 is allowed from where you are.
  • Permission denied. The network path is fine and authentication failed. Check the username, which key is being offered, and the permissions on the server's authorized_keys file.
  • Host key verification failed. The stored host key does not match. Confirm the reason before removing the old entry from known_hosts.

Run the client in verbose mode to see where it stops:

ssh -v user@example.com
ssh -p 2222 user@example.com

The second form connects to a server listening on a non-default port.

Hardening

Any server with port 22 open to the internet receives a steady stream of automated login attempts. Common measures:

  • Use key-based authentication and disable password login.
  • Disable direct root login.
  • Restrict the port to known source addresses, or reach it through a VPN or bastion host.
  • Keep the SSH server software updated.

Moving SSH to another port cuts down log noise from scanners. It does not replace the measures above, since scanners check other ports too.

Related

Encrypted web traffic uses port 443. If ssh reports that it cannot resolve the hostname, the problem is DNS: see port 53.

IANA registration

This is the assignment for port 22 exactly as the registry lists it, one row per service name and transport.

Service name Transport Description Reference
ssh TCP The Secure Shell (SSH) Protocol RFC 4251
ssh UDP The Secure Shell (SSH) Protocol RFC 4251
ssh SCTP SSH RFC 9260

Assignment notes in the registry:

  • Defined TXT keys: u=<username> p=<password>

Source: IANA Service Name and Transport Protocol Port Number Registry, as downloaded on December 5, 2026. The registry changes over time; the linked page is the authority.

A registration records who a port number is assigned to. It does not prove that whatever is listening on the port is that service, and it does not mean the service uses every transport listed: older entries were routinely registered for both TCP and UDP.

Port range

Port 22 falls in the well-known (system) port range, 0 to 1023. RFC 6335 calls these System Ports. IANA assigns them only through the IETF Review or IESG Approval procedures, the strictest rules of the three ranges. On Unix-like systems a program has traditionally needed root privileges to listen on a port below 1024.

The other ranges are registered (user) ports (1024 to 49151) and dynamic (private) ports (49152 to 65535). The ranges and the assignment rules are defined in RFC 6335.

Look up another port in the port table.