Toolman

What port does SSH use?

SSH uses port 22 over TCP.

PortProtocolNameWhat it is for
22TCPSSH / SFTPSecure Shell — remote terminal access, and the transport for SFTP and SCP. Also what Git uses over SSH.

Exposing it

The single most brute-forced port on the internet. Disable password authentication, use keys only, and consider fail2ban. Moving to a non-standard port reduces log noise but is not security.

Checking it is listening

sudo lsof -i :22          # macOS, Linux
netstat -ano | findstr :22   # Windows
nc -zv host 22               # from elsewhere

An "address already in use" error on a port nothing appears to be holding usually means the socket is in TIME_WAIT rather than that a process has it — the ports reference covers that and the ephemeral range.

Frequently asked questions

What port does SSH use?

SSH uses port 22 over TCP. Secure Shell — remote terminal access, and the transport for SFTP and SCP. Also what Git uses over SSH.

Is port 22 safe to expose to the internet?

The single most brute-forced port on the internet. Disable password authentication, use keys only, and consider fail2ban. Moving to a non-standard port reduces log noise but is not security.

How do I check whether SSH is listening?

sudo lsof -i :22 on macOS or Linux, netstat -ano | findstr :22 on Windows. From another machine, nc -zv host 22 says whether anything answers.

Other services

Port 22 in full · Every service · All port numbers