Free tech learning for everyone, from basics to pro

Port 20-21: FTP (File Transfer Protocol)

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

Port20-21
TransportTCP
ServiceFile Transfer Protocol (FTP)
EncryptedNo

What is port 20-21?

FTP moves files between a client and a server. TCP 21 carries the control channel (login and commands); data travels on TCP 20 in active mode or on a high random port in passive mode.

Common uses

  • Uploading website files to older hosting
  • Moving files to and from legacy systems and devices
  • Firmware transfers on some network equipment

Security risks

  • Usernames, passwords and files travel in plain text, so anyone on the path can read them
  • Anonymous FTP left enabled exposes files to the whole internet
  • Brute-force password attacks against exposed servers

How to secure port 20-21

  • Replace FTP with SFTP (over SSH, port 22) or FTPS (FTP over TLS)
  • Never expose FTP to the internet; restrict it to known IP addresses if it must exist
  • Disable anonymous login
  • Use strong, unique passwords and lock out repeated failures

How to check if port 20 is open

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

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 FTP from the internet
 deny   tcp any any eq 20
 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 20-21 used for?

Port 20-21 (TCP) is used by File Transfer Protocol (FTP). FTP moves files between a client and a server.

Is it safe to open port 20-21?

Only if the service needs to be reached and is configured securely. Replace FTP with SFTP (over SSH, port 22) or FTPS (FTP over TLS).

How do I check if port 20-21 is open?

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

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