Port 22 is the default port for SSH, the encrypted protocol used for remote shell access, SFTP file transfer and Git over SSH. It is normally meant to be reachable from the internet.
- Port
- 22
- Protocol
- TCP
- Service
- SSH
- Expose to internet?
- Yes, usually
- Also used by
- OpenSSH, SFTP, SCP, Git over SSH
Is port 22 safe to open?
SSH is encrypted and safe to expose when configured well, and most servers need it reachable for administration. Any public port 22 receives continuous automated login attempts, so password authentication is the main weakness. With key-only authentication and root login disabled, brute force is no longer a practical threat.
How to secure SSH
- Use key-based login and set
PasswordAuthentication noin /etc/ssh/sshd_config. - Set
PermitRootLogin no(orprohibit-password) and log in as a normal user with sudo. - Limit who can log in with
AllowUsersorAllowGroups. - Install fail2ban or sshguard to block addresses that repeatedly fail.
- Where possible, allow port 22 only from your office IP or VPN range.
Check if port 22 is open
Linux: what is listening on this port
sudo ss -tlpn | grep ':22 'Windows (PowerShell): what is listening
Get-NetTCPConnection -LocalPort 22 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}From another machine: is it reachable
nc -zv HOST 22
# or
nmap -p 22 HOST
# Windows
Test-NetConnection HOST -Port 22Test the SSH service itself
ssh -v -o BatchMode=yes USER@HOST exitOpen port 22 in the firewall
ufw (Ubuntu, Debian)
sudo ufw allow 22/tcpfirewalld (RHEL, Rocky, Alma, Fedora)
sudo firewall-cmd --permanent --add-port=22/tcp
sudo firewall-cmd --reloadWindows Firewall (PowerShell, as Administrator)
New-NetFirewallRule -DisplayName "Allow 22/TCP" -Direction Inbound -Protocol TCP -LocalPort 22 -Action AllowMonitor port 22
Add a TCP port monitor for 22 and Statance connects to it from up to six regions, alerting you by email, Slack, Discord or PagerDuty when SSH stops answering. TCP port monitoring.
Related ports
FAQ
Does changing the SSH port from 22 improve security?
It cuts down log noise from automated scanners, but it is not a security control on its own. Key-only authentication and disabling root login matter far more.
Is it safe to leave port 22 open?
Yes, if password authentication is off and the server is patched. Restricting the port to known IP addresses or a VPN is safer still.
What is port 22 used for?
Port 22 is the default port for SSH, the encrypted protocol used for remote shell access, SFTP file transfer and Git over SSH. It is also used by OpenSSH, SFTP, SCP, Git over SSH.
Is port 22 TCP or UDP?
SSH uses TCP on port 22.
How do I check if port 22 is open?
On the server, run sudo ss -tulpn | grep ':22 ' (Linux) or Get-NetTCPConnection -LocalPort 22 (Windows) to see what is listening. From another machine, run nc -zv HOST 22 or Test-NetConnection HOST -Port 22.
Know the moment a port stops answering.
TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.