What Is the Port for SFTP: Default Number and How to Check Yours

đŸ’„ Quick Answer

The port for SFTP is 22 by default, since it runs over SSH’s secure connection. Many servers keep this standard, though custom ports are possible and can be checked via network tools or configuration files.

The port 22 connection isn’t just a coincidence—it’s because SFTP rides on SSH’s encrypted tunnel, inheriting its security and protocol. đŸ”„ This shared foundation means your data stays protected during transfers, unlike plain FTP which uses unencrypted ports like 20/21.

I’ve seen admins change this port for security through obscurity, but it requires updating both server configs and client connections. Always double-check your firewall rules after making changes!

💡 In This Article

  • How SFTP Port 22 Works with SSH
  • How to Verify or Change Your SFTP Port

How SFTP port 22 works with SSH

SFTP—or Secure File Transfer Protocol—doesn’t operate independently. Instead, it runs as a subsystem of SSH (Secure Shell) over the same port 22. This means every SFTP connection is automatically encrypted using SSH’s robust cryptographic protocols, including AES-256 or ChaCha20 for data encryption and RSA/ECDSA for authentication.

When you initiate an SFTP transfer, your client first establishes an SSH session, then requests the SFTP service over that secure tunnel.

The shared port design isn’t just convenient—it’s a security feature. SSH’s port 22 has been the standard since 1995 when the protocol was introduced. Unlike FTP, which uses unencrypted ports 20 (data) and 21 (command), SFTP inherits SSH’s built-in protections against eavesdropping, man-in-the-middle attacks, and data tampering.

This is why even basic file transfers through SFTP achieve FIPS 140-2 Level 2 compliance out of the box—something FTP could never match without additional VPN layers.

Here’s what happens under the hood: When you connect to port 22, your client and server perform a key exchange (using Diffie-Hellman or Elliptic Curve Diffie-Hellman) to establish a shared secret. This secret then generates symmetric encryption keys for the session.

SFTP commands (like PUT, GET, or LIST) are sent through this encrypted channel, with each packet individually authenticated using HMAC-SHA256 to prevent spoofing.

You might wonder why servers sometimes use non-standard ports (like 2222 or 10022). The reason is often security through obscurity—hiding the default port from automated scans. However, this only works if combined with proper firewall rules and authentication hardening.

Without these, changing ports offers minimal protection. What’s more important is that SFTP’s encryption remains active regardless of the port number, since it’s fundamentally tied to SSH’s protocol stack.

For comparison, consider how FTP works: it sends usernames, passwords, and file contents in plaintext over ports 20/21. An attacker sniffing network traffic could easily capture credentials or modify files during transfer. SFTP eliminates this entirely by wrapping all communication in SSH’s encrypted tunnel.

This is why SFTP has become the de facto standard for secure file transfers in enterprise environments, government systems, and even personal use cases like website backups.

One practical implication is that SFTP connections require the same level of authentication as SSH itself. This means you’ll need valid credentials (username/password or SSH key pair) to establish the connection. The port number alone won’t grant access—it’s the encrypted handshake that verifies your identity before any file operations begin.

This dual-layer security is what makes SFTP so reliable for sensitive data transfers.

Frequently asked questions

1

Why does SFTP use port 22 instead of a dedicated port?

SFTP runs as a subsystem of SSH over port 22 because it leverages SSH’s existing encrypted connection. This design ensures all file transfers inherit SSH’s security features (like AES encryption) without needing separate infrastructure. The shared port simplifies configuration while maintaining strong protection against eavesdropping or tampering.

2

Can I use any port for SFTP if I change the SSH configuration?

Yes, but you must update both the server’s SSH config (e.g., /etc/ssh/sshd_config) and client connections. For example, changing to port 2222 requires restarting SSH and updating firewall rules. Always test with a simple file transfer first to confirm the new port works before relying on it for production.

3

What happens if I block port 22 but SFTP still needs it?

Blocking port 22 without changing the SSH config will break SFTP connections entirely. If you’re hardening security, either:

  1. Change the SSH port (and update clients/firewalls), or
  2. Use a VPN to encrypt all traffic before it reaches port 22. Never leave port 22 open if you’re not using it—this is a common attack vector for brute-force exploits.
4

How do I know if my SFTP server is using a custom port?

Check with these commands:

  • Linux: ss -tulnp | grep ssh or netstat -tulnp | grep ssh
  • Windows: netstat -ano | findstr ssh If the output shows anything other than port 22, that’s your custom SFTP port. Verify firewall rules allow traffic on that port to avoid connection issues.
5

Is there a performance difference between port 22 and custom SFTP ports?

No—SFTP performance depends on your network speed and server resources, not the port number. Custom ports (like 2222) don’t add latency or overhead. The only impact comes from misconfigurations (e.g., firewall rules blocking the new port) or weak encryption settings in your SSH config.

Final thoughts

Understanding the SFTP port is simple once you know the basics! By default, SFTP uses port 22, just like SSH, but it’s always smart to verify your server’s configuration—especially if you’re troubleshooting connection issues.

Whether you’re setting up a secure file transfer or debugging an error, knowing how to check your port (via command line, SSH config, or third-party tools) ensures smooth, secure transfers every time. 🔒 With this guide, you’re now equipped to handle SFTP like a pro—no guesswork required!

★★★★★4.5(13 reviews)
Michael Davis