What port does SSH use?
SSH uses port 22 over TCP.
| Port | Protocol | Name | What it is for |
|---|---|---|---|
| 22 | TCP | SSH / SFTP | Secure 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
- What port does RDP use?
- What port does MySQL use?
- What port does PostgreSQL use?
- What port does SQL Server use?
- What port does Oracle use?
- What port does MongoDB use?
- What port does Redis use?
- What port does Memcached use?
- What port does Elasticsearch use?
- What port does DNS use?
- What port does NTP use?
- What port does SMB use?