Port 22 (SSH)

Port 22 is the default TCP port of SSH and SFTP: tests with ss and nc, firewall rules, usual errors and hardening.

loading Port 22 (SSH)
About this tool

Port 22: what it is

Port 22 is where SSH, the Secure Shell, listens by default. It carries remote command lines, file copies with scp and SFTP, and tunnels to other ports, all inside one encrypted connection. IANA registered it for SSH; telnet, which sends everything in clear text, lives on port 23.

In the port lookup it is listed as SSH, SFTP on TCP. This page opens that tool on 22.

  • Remote shell: ssh user@host opens a terminal on the server.
  • File transfer: scp and sftp use the same port; FTPS, a different thing, uses 21 or 990.
  • Tunnels and git: ssh -L forwards a local port to a remote one, and git over SSH (git@github.com) connects here too.

Test it and open it

Is the server listening, and can I reach it?

sudo ss -ltnp | grep ":22"       # on the server
nc -vz server.example.com 22      # from your machine
ssh -v user@server.example.com    # shows each step of the handshake

Open the port, or use another one

sudo ufw allow 22/tcp
# /etc/ssh/sshd_config
Port 2222
ssh -p 2222 user@server.example.com

Errors you will meet

MessageWhat it usually means
Connection refusedThe host answered, but nothing listens on that port: sshd is stopped or on another port.
Connection timed outNo answer at all: a firewall or security group drops the packets, or the address is wrong.
Permission denied (publickey)The server is reachable, but it did not accept your key: wrong user, wrong key, or the file mode of the key is too open (it must be 600).

Keep it safe

  • Use keys, not passwords, and set PasswordAuthentication no in sshd_config once your key works.
  • Do not allow root login (PermitRootLogin no) and limit who may connect with AllowUsers.
  • Moving SSH to another port does not secure it, it only quiets the log of bots; use a firewall allow-list and fail2ban for the real protection.

Neighbours in the same category

Other remote access ports in the lookup tool:

PortProtocolServiceSource
22TCPSSH, SFTPIANA registry
23TCPTelnetIANA registry
3389TCP/UDPRDPIANA registry
5900TCPVNCIANA registry
5985TCPWinRM HTTPIANA registry
5986TCPWinRM HTTPSIANA registry
6000TCPX11IANA registry

Look up another port

  1. Type a port number (443), a range (8000-8100) or a word (database) in the search box.
  2. Filter by protocol (TCP or UDP) or by category with the buttons above the table.
  3. Copy a line, or print the table as a one-page reference.

Frequently asked questions

Is port 22 TCP or UDP?

TCP. SSH needs a reliable ordered stream, so there is nothing to open on UDP.

Should I change the SSH port?

It is optional and cosmetic: it cuts the noise of automated scans in the log, but a scanner finds the new port in seconds. Keys and a firewall are what protect you.

Why does SFTP use port 22 and not 21?

SFTP is not FTP over SSL: it is a subsystem of SSH, so it rides on the SSH connection. FTP and FTPS have their own ports.

Report a problem