Free tech learning for everyone, from basics to pro

Port 22: SSH (Secure Shell (also SFTP and SCP))

What port 22 (TCP) does, the security risks of leaving it open, and how to secure and test it.

Port22
TransportTCP
ServiceSecure Shell (also SFTP and SCP) (SSH)
EncryptedYes

What is port 22?

SSH gives an encrypted command line on a remote computer or network device. SFTP and SCP use the same port to copy files securely.

Common uses

  • Managing Linux servers, routers, switches and firewalls
  • Secure file transfer with SFTP and SCP
  • Tunnelling other traffic through an encrypted connection

Security risks

  • Constant automated password-guessing attacks against internet-facing SSH
  • Weak or reused passwords and old, unpatched SSH software
  • Stolen private keys giving silent access

How to secure port 22

  • Use key-based authentication and disable password login where possible
  • Disable direct root login
  • Allow SSH only from management networks or through a VPN
  • Keep OpenSSH and device firmware patched
  • On Cisco devices, use SSH version 2 only and remove Telnet

How to check if port 22 is open

WhereCommand
Scan from another machinenmap -p 22 <host>
Windows (PowerShell)Test-NetConnection <host> -Port 22
Linux (what is listening)sudo ss -tulpn | grep :22
Windows (what is listening)netstat -ano | findstr :22

Only scan systems you own or have permission to test.

Example: block it at the internet edge (Cisco)

For a service that should stay inside your network, deny it on the internet-facing interface. Put the rule before any broader permit statements:

ip access-list extended INTERNET-IN
 remark Block SSH from the internet
 deny   tcp any any eq 22
 permit ip any any
!
interface GigabitEthernet0/0
 ip access-group INTERNET-IN in

In a real network the final line would be your normal inbound policy, not "permit ip any any". Build and check rules with the ACL builder.

Related ports

Frequently asked questions

What is port 22 used for?

Port 22 (TCP) is used by Secure Shell (also SFTP and SCP) (SSH). SSH gives an encrypted command line on a remote computer or network device.

Is it safe to open port 22?

Only if the service needs to be reached and is configured securely. Use key-based authentication and disable password login where possible.

How do I check if port 22 is open?

From another computer, run nmap -p 22 followed by the host address. On the server itself, ss -tulpn on Linux or netstat -ano on Windows shows whether anything is listening on 22.

Learn more: TCP, UDP and ports explained and firewall basics.

Get free updates by email

New notes, tools, CCNA and Security+ tips and important security news from FM TecHub, explained simply. Free, about twice a month. Unsubscribe anytime; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesup

Free · no spam · past emails · powered by Buttondown