Port 22 is the default TCP port for SSH (Secure Shell), the protocol for encrypted remote login, file transfer, and tunneling to servers. IANA assigned port 22 to SSH, between FTP on port 21 and Telnet on port 23. Because it is well known and often exposed, port 22 is constantly scanned and brute-forced, so open it only where needed and protect it with keys, MFA, and firewall rules.
Key takeaways
- Port 22 is the default port for SSH, used for secure remote login, SFTP file transfer, and tunneling.
- Open port 22 on the internet is scanned and brute-forced constantly, so password-only SSH is a real risk.
- Key-based login, MFA, firewall allow-listing, and fail2ban-style blocking are the core defenses.
If you run a server, port 22 is probably its front door. It is the default port for SSH, the protocol administrators use to log in, move files, and manage machines remotely — and it is also one of the most scanned ports on the internet.
What is port 22?
Port 22 is the default TCP port for SSH (Secure Shell), the encrypted protocol used for remote login, file transfer, and tunneling. IANA, the body that assigns port numbers, registered port 22 for SSH.
A port is a numbered channel that directs network traffic to a specific service on a machine. When your SSH client connects to a server, it sends traffic to port 22, where the SSH server program — usually OpenSSH sshd — is listening. The server then negotiates encryption, checks who you are, and opens a shell session.
The number itself is a historical accident. In 1995, SSH creator Tatu Ylönen asked IANA for a port and chose 22 because it was free and sat neatly between FTP on port 21 and Telnet on port 23, the two protocols SSH was designed to replace. SSH would work identically on any port.
What is SSH and how does it work?
SSH is a cryptographic network protocol that creates an encrypted connection between two computers over an unsecured network. It authenticates both sides, encrypts everything sent, and checks that data has not been tampered with.
A typical connection has three phases. First, the client and server agree on encryption through a key exchange. Second, the server proves its identity with a host key, and the user proves theirs with a password or, better, a cryptographic key. Third, an encrypted session opens and commands, output, and files travel inside it.
SSH is defined by RFC 4251 and related standards, which describe its transport, authentication, and connection layers. Cloudflare's SSH guide explains the same flow in plain terms: SSH sets up a connection, encrypts it, and lets you control a faraway machine as if you were sitting in front of it.
What runs on port 22?
Far more than interactive logins runs on port 22. SFTP and SCP file transfers are SSH subsystems, Git hosting accepts pushes over SSH, and automation tools such as Ansible administer whole fleets through it.
| Use | What it does | Typical tool |
|---|---|---|
| Remote shell | Run commands on a server as if you were there | ssh, OpenSSH |
| File transfer | Copy files securely in either direction | SFTP, SCP, rsync over SSH |
| Git hosting | Push and pull code over an encrypted channel | Git over SSH |
| Tunneling | Forward a port or encrypt another protocol inside SSH | ssh -L / -D |
| Automation | Run the same commands across many servers | Ansible, scripts |
Because so much infrastructure depends on it, a broken or blocked port 22 can stop deployments, backups, and monitoring. That is why teams treat SSH access as critical infrastructure, not a convenience.
Port 22 vs port 21, 23, 80, and 443: what's the difference?
Port numbers tell a computer which service should receive the traffic. Port 22 is SSH, port 21 is FTP, port 23 is Telnet, port 80 is HTTP, and port 443 is HTTPS. The security difference is what matters most.
| Port | Service | Encrypted? | Use today |
|---|---|---|---|
| 21 | FTP | No | Legacy file transfer; avoid on the internet |
| 22 | SSH | Yes | Remote login, SFTP, tunneling |
| 23 | Telnet | No | Almost never; passwords travel in clear text |
| 80 | HTTP | No | Web traffic, usually redirected to 443 |
| 443 | HTTPS | Yes | Encrypted web traffic |
Telnet and FTP send passwords in clear text, which is why SSH replaced them. If you still see port 23 open anywhere, treat it as a finding, not a feature. You can check whether a site redirects HTTP to HTTPS with our free SSL checker.
Is port 22 dangerous?
Port 22 itself is not dangerous — it is a doorway, and the danger depends on what guards it. An SSH server with strong keys and tight firewall rules is a normal, safe part of running infrastructure.
The risk comes from exposure plus weak login. Automated bots sweep the internet looking for open port 22, then try common usernames and passwords thousands of times. A server that allows password login for root is the easiest target they will find all day.
SSH vulnerabilities also appear in CISA's Known Exploited Vulnerabilities catalog when a flaw is actively exploited in the wild. That is why patching the SSH server itself matters as much as hardening its settings — see our guide to Linux patch management for a routine that covers it.
How do I check if port 22 is open?
On the server, run sudo ss -ltnp and look for a line listening on port 22; it will show which process owns it. That tells you the truth about the server itself, not just what a firewall lets through.
From another machine, run ssh -v user@host. The verbose output shows each stage of the connection, and the last lines tell you where it broke. "Connection refused" usually means nothing is listening. "Connection timed out" usually means a firewall is dropping the traffic. "Permission denied (publickey)" means the server answered but rejected your key.
Do not scan port 22 on systems you do not own or have permission to test. Port scanning someone else's server without authorization can be treated as unauthorized access in many places.
How do I secure port 22?
Secure SSH in layers, starting with the login method. Disable password authentication, require SSH keys, disable root login, and add MFA where your setup supports it. A stolen password should never be enough on its own.
- Use keys, not passwords. Generate an Ed25519 key pair, copy the public key to the server, and set
PasswordAuthentication noinsshd_config. - Disable root login. Set
PermitRootLogin noand log in as a normal user, then usesudo. - Limit who can reach it. Allow port 22 only from your office or VPN IP ranges in the firewall, or put SSH behind a bastion host or VPN.
- Block brute force. Use fail2ban or your firewall to temporarily block IP addresses that fail too many logins.
- Keep OpenSSH updated. Patch promptly when a new OpenSSH release fixes a vulnerability.
- Watch the logs. Review failed login attempts regularly and alert on unusual success patterns, such as logins at odd hours.
Should I change SSH from port 22?
Changing SSH to a non-standard port such as 2222 reduces the noise from automated scans, because most bots only probe port 22. It does not stop a determined attacker, who can scan all ports and fingerprint the SSH service.
Think of it as moving a house number, not adding a lock. It is fine as an extra layer, but it must sit on top of keys, MFA, and firewall rules — never instead of them. Changing the port also adds friction: every user, script, and tool must be told the new port with ssh -p 2222 user@host.
For most small teams, the better investment is restricting port 22 to trusted IP addresses. That removes the internet-wide scanning problem entirely, which a port change only hides.
Common port 22 mistakes to avoid
The most common mistake is leaving password authentication on with a weak or reused password. The second is allowing root login directly, which hands attackers a known username to guess against.
- Leaving SSH open to the whole internet when only two people ever use it.
- Reusing one SSH key across many servers and never rotating it when someone leaves.
- Never checking logs, so a slow brute-force attack runs for months unnoticed.
- Running an old OpenSSH version with known vulnerabilities.
- Forwarding port 22 from a home router to a server without any firewall rules.
If you manage a home network, our guide to how to secure your Wi-Fi covers the router side of the same problem.
Who needs to know about port 22?
Anyone who runs a Linux server, a VPS, a Raspberry Pi, or cloud infrastructure will meet port 22. Developers use it for Git and deployments, system administrators use it for daily management, and home-lab owners use it to reach machines on their network.
If you only use shared hosting or a managed platform, you may never touch SSH directly — and that is fine. But if a scan report, a firewall alert, or a hosting dashboard ever mentions port 22, you now know what it means and what to ask about.
The bottom line
Port 22 is the default home of SSH: encrypted remote access, file transfer, and tunneling for servers. It is safe when it is guarded with keys, MFA, and tight firewall rules, and risky when it is left open with password login.
Start by checking what is listening on your servers and who can reach it. You can map the public side of that picture with our free DNS lookup and our attack-surface guidance, then close every door you do not actually need.
Frequently asked questions
What is port 22 used for?
Port 22 is used by SSH for encrypted remote login to servers, plus SFTP and SCP file transfers, Git over SSH, and SSH tunneling. When you run ssh user@server, your client connects to port 22 on that server by default.
Is port 22 TCP or UDP?
Port 22 is registered for TCP, UDP, and SCTP, but SSH in practice uses TCP. If you are writing a firewall rule for SSH, allow TCP port 22 unless you have a specific reason to do otherwise.
Is it safe to leave port 22 open?
It is safe only if SSH is hardened: key-based login instead of passwords, MFA where possible, no root login, and access limited to trusted IP addresses. An open port 22 with password login will be brute-forced by automated bots.
Should I change SSH from port 22 to another port?
Changing the port reduces scan noise but is not real security, because scanners can find SSH on any port. Do it only as an extra layer on top of keys, MFA, and firewall rules, never instead of them.
What is the difference between port 22 and port 443?
Port 22 is the default for SSH remote access, while port 443 is the default for HTTPS web traffic. Both are encrypted, but they serve different protocols and different services.
How do I check if port 22 is open on a server?
From a terminal, run ssh -v user@host to see the connection attempt, or use ss -ltn on the server itself to see whether anything is listening on port 22. A connection refused error usually means nothing is listening; a timeout usually means a firewall is blocking it.
Why do attackers scan port 22 so much?
Because SSH gives full control of a server, and many servers still allow password login. Bots sweep the internet for open port 22, then guess common usernames and passwords automatically, day and night.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the IANA port registry, RFC 4251, Cloudflare's SSH guide, and CISA's Known Exploited Vulnerabilities catalog.
How we write and fact-check →