Why is SFTP safer than FTP?

The short answer

SFTP (SSH File Transfer Protocol) is safer because every command and file travels inside one encrypted SSH (Secure Shell) connection, while plain FTP sends your password and files as readable text.

Animated diagram: Why is SFTP safer than FTP?

FTP vs SFTP

FTP (File Transfer Protocol) dates from 1971, when the few computers on the network trusted each other, so it has no encryption built in. Your username, your password, and every file you upload leave the laptop as readable text. Anyone who can see the traffic, for example on an open café Wi-Fi, can read them.

SFTP (SSH File Transfer Protocol) does the same job, uploading and downloading files, but it was designed for networks you cannot trust. It is a different protocol built on SSH (Secure Shell), the encrypted remote login that admins already use, on port 22.

What plain FTP actually sends

An FTP session uses two connections. The first one, the control connection on port 21, carries the commands: USER with your username, PASS with your password, then STOR to upload or RETR to download a file. The file itself travels over a second, separate data connection. Neither connection is encrypted, so a simple capture of the Wi-Fi shows the login and the file content in plain letters.

FTP also cannot tell you whether you are really talking to your server. If someone on the same network redirects your connection, your client sends the password to them without any warning.

How SFTP protects the same upload

  1. One encrypted connection. Your client opens a single SSH connection on port 22. Client and server first agree on a secret session key, so everything that follows is encrypted.
  2. The server proves who it is. The server signs that exchange with its host key. Your client compares it with the key it saved on your first connection. If it changed, you get a warning instead of a login, which stops a fake server from collecting your password.
  3. You log in inside the tunnel. Your password, or better an SSH key, is sent only after the connection is encrypted.
  4. Files travel inside SSH. Your client starts SSH’s built-in file service, the SFTP subsystem. Every command and every file goes through that one encrypted connection, with no second data connection to protect or to open in a firewall.

The result: a capture of the same café Wi-Fi shows only scrambled bytes. Nobody can read the password or the file, and nobody can change the file on the way without the connection noticing it.

SFTP is not FTPS

The names are close, but they are two different things. FTPS is classic FTP with TLS (Transport Layer Security), the same encryption HTTPS uses, switched on with an AUTH TLS command. It keeps FTP’s two connections and its ports. SFTP has nothing to do with FTP apart from the name: it is part of SSH. Both encrypt your login and your files. Plain FTP does neither.

What to do

  • In your file client (for example FileZilla, WinSCP, or Cyberduck), switch the protocol from FTP to SFTP and use port 22.
  • On the first connection, check the host key fingerprint against the one your hosting provider shows you, then let the client remember it.
  • Prefer an SSH key to a password if your host allows it.
  • If a client or a web host still gives you an FTP login, ask for SFTP access instead. Most hosting providers offer it.

Watch it in 60 seconds