
What Is SFTP? How Secure File Transfer Protocol Works (and Why It Beats FTP)
What is SFTP? SFTP, or SSH File Transfer Protocol, is a secure way to transfer files between a computer and a server over an encrypted connection. The older File Transfer Protocol (FTP) sends usernames, passwords, and files in plain text, so anyone who intercepts the connection can read them. SFTP fixes that by running every transfer through a secure SSH tunnel.
In this guide, you will learn what SFTP is, how it works, how it compares with FTP and FTPS, which port it uses, how to connect with popular clients and the command line, and why it is the safer choice for almost every file transfer.
What Is SFTP?
SFTP stands for SSH File Transfer Protocol. It is a network protocol that lets you upload, download, rename, delete, and manage files on a remote server, all over a secure, encrypted connection provided by SSH (Secure Shell). Despite the similar name, SFTP is not simply a secure version of FTP. It is a completely different protocol, designed from the start to work inside SSH, rather than being FTP with encryption added on top.
When you use SFTP, nothing travels in plain text: not your username and password, the commands you send, the file names, or the file contents. Only the server you are connected to can decrypt them. That is why banks, hospitals, web hosts, and developers use SFTP for sensitive files, from customer records to website code. Most servers that allow SSH access already support SFTP, so there is usually nothing extra to install.
How Does SFTP Work?
SFTP opens a single secure connection to the server and sends all commands and data through it:
- You start a connection. Your client connects to the server on port 22, the standard port for SSH and SFTP.
- The server proves its identity. It presents its host key, a cryptographic fingerprint. Your client warns you if it has changed, which could indicate an impersonation attempt.
- You authenticate. You log in with a username and password, or, more securely, with an SSH key pair. The private key stays on your computer.
- An encrypted tunnel is created. Client and server agree on encryption algorithms and exchange session keys. From then on, everything is encrypted.
- You transfer files. Commands such as listing a directory, uploading, or downloading travel through the tunnel, and the server checks your permissions for each action.
- The connection closes securely. When you disconnect, the session keys are discarded, so the session cannot be replayed later.
Because SFTP uses just one connection, it is also easier to configure through firewalls than FTP: a firewall only needs to allow traffic on port 22.
What Encryption Does SFTP Use?
SFTP relies on the encryption built into SSH, typically strong symmetric encryption such as AES, plus public-key cryptography to authenticate the server and user. Learn more in our guide to what AES encryption is and how it works.

SFTP vs FTP vs FTPS: What Is the Difference?
FTP is the original protocol, dating back to the 1970s. FTPS is FTP with TLS encryption added. SFTP is a separate protocol that runs over SSH. The table below summarises the differences.
| Feature | SFTP | FTP | FTPS |
|---|---|---|---|
| Full name | SSH File Transfer Protocol | File Transfer Protocol | FTP over SSL/TLS |
| Underlying protocol | SSH | TCP, no encryption layer | FTP with TLS/SSL |
| Default port | 22 | 21 (control), 20 (data) | 21, plus data ports |
| Encryption | Yes, everything is encrypted | No, plain text | Yes, when configured correctly |
| Credentials protected | Yes | No, sent in plain text | Yes, with TLS |
| Data protected | Yes | No | Yes, with TLS |
| Firewall friendly | Yes, single port 22 | No, needs multiple ports | Partly, needs extra ports |
| Authentication | Password or SSH keys | Username and password | Username and password, plus certificates |
| File management | Upload, download, rename, delete, set permissions | Upload, download, basic commands | Same as FTP, over TLS |
| Best for | Secure transfers, most use cases | Legacy systems only, never for sensitive data | Secure transfers where FTP infrastructure already exists |
For a closer look at the FTP-with-encryption option, see our guide to what FTPS is. In most situations, however, SFTP is the simpler choice, because it needs only one port and one protocol, and there is no unencrypted fallback to misconfigure.
Why Is SFTP Safer Than FTP?
FTP was designed when networks were smaller and more trusted. It sends everything, including your login details, in plain text. SFTP was designed for the modern internet, where traffic should be assumed to be observable:
- Everything is encrypted. With FTP, anyone who intercepts traffic can read your password and files. With SFTP, they see only encrypted data.
- Credentials are protected. FTP passwords are easy to steal with a packet capture. SFTP passwords and SSH keys are never sent in usable plain-text form.
- The server is verified. SFTP checks the server’s host key before you log in, helping prevent man-in-the-middle attacks. FTP has no equivalent check.
- Files cannot be tampered with in transit. SFTP uses integrity checks, so altered data is detected. FTP offers no such protection.
- Access is controlled per user. SFTP permissions are tied to SSH accounts, so each user can be limited to the folders they need.
- There is no insecure fallback. A misconfigured FTPS server can accidentally allow plain FTP. SFTP has no plain-text mode.
The rule is simple: if a transfer involves a password, personal data, business documents, or website files, use SFTP, not FTP.
How to Connect to SFTP
Connecting takes only a few minutes. You need the server’s hostname or IP address, your username, and your password or SSH key, usually the same details you use for SSH access.
Popular SFTP Clients
- FileZilla (Windows, macOS, Linux, free). The most widely used graphical SFTP client; enter the host, username, password, and port 22.
- WinSCP (Windows, free). A popular Windows client with a dual-pane interface and support for SSH keys.
- Cyberduck (Windows, macOS, free). A clean, beginner-friendly client that also works with cloud storage.
- Transmit (macOS, paid). A polished Mac client for people who transfer files every day.
- Command line (macOS, Linux, and Windows with OpenSSH). Use the built-in
sftpcommand for quick transfers and scripting.
Connect With FileZilla in 5 Steps
- Open FileZilla, click File > Site Manager, then click New Site.
- Set the protocol to SFTP – SSH File Transfer Protocol.
- Enter the host (your domain or server IP), set the port to 22, and choose Normal as the logon type.
- Enter your username and password, or select Key file for SSH keys, then click Connect.
- Check the host key against the fingerprint your host gave you, then accept it. Drag files between the local and server panes to transfer them.
Connect From the Command Line
On macOS or Linux, open Terminal and type sftp username@your-server.com. You will be asked for your password, or your SSH key will be used automatically. To use a different port, add -P, for example sftp -P 2222 username@your-server.com.
Common SFTP Commands
These are the commands you will use most often. Commands beginning with l, such as lpwd, act on your local computer; the others act on the remote server.
| Command | What It Does | Example |
|---|---|---|
ls |
List files in the current remote folder | ls |
pwd |
Show the current remote folder | pwd |
cd |
Change the remote folder | cd /var/www/html |
lcd |
Change the local folder | lcd ~/Documents |
get |
Download a file from the server | get report.pdf |
put |
Upload a file to the server | put index.html |
mget |
Download several files at once | mget *.jpg |
mput |
Upload several files at once | mput *.html |
mkdir |
Create a folder on the server | mkdir backups |
rm |
Delete a file on the server | rm old-file.txt |
rename |
Rename a file or folder on the server | rename old.txt new.txt |
chmod |
Change file permissions on the server | chmod 644 file.txt |
exit or bye |
Close the SFTP session | exit |
SFTP Security Best Practices
Using SFTP is a big improvement over FTP, but a few habits make it far more secure:
- Use SSH keys instead of passwords where possible. A key pair is much harder to guess than a password. Protect your private key with a passphrase and never share it.
- Use strong, unique passwords. If you use password authentication, choose a long, unique password and store it in a password manager.
- Verify the host key the first time you connect. Check the fingerprint against the one your host provides, and investigate if it ever changes.
- Give each user only the access they need. Create separate accounts, limit them to the folders they need, and remove accounts when they are no longer needed.
- Disable plain FTP on your server. If FTP is still enabled, someone may use it by mistake. Turn it off and allow only SFTP and SSH.
- Keep software updated and monitor logins. Updates fix security flaws in SSH and SFTP software, and login logs can reveal brute-force attempts early.
When to Use SFTP (and When Not To)
Use SFTP when you need to transfer files securely: uploading website files, sharing confidential documents, moving backups, exchanging data with partners, or managing a remote server. It is the default choice for most secure file transfers.
Do not use it for public file downloads that anyone should be able to access, such as software downloads from a public mirror; a web server or content delivery network is a better fit. Also avoid older, insecure protocols for routine transfers. For example, the Trivial File Transfer Protocol has no authentication or encryption at all, as explained in our guide to TFTP and whether it is safe to use. If a system only supports FTP or TFTP, transfer only non-sensitive files and plan to upgrade it.
Frequently Asked Questions About SFTP
What is SFTP used for?
SFTP is used to securely transfer and manage files on a remote server: uploading website files, downloading backups, sharing confidential documents, exchanging data between businesses, and managing files on a web server or cloud server.
What port does SFTP use?
SFTP uses port 22 by default, the same port as SSH, because SFTP runs over SSH. Some servers use a custom SSH port, in which case your host will tell you the correct number.
Is SFTP the same as FTP?
No. FTP sends data and credentials in plain text over ports 20 and 21, while SFTP runs over SSH on port 22 and encrypts everything, including usernames, passwords, commands, and file contents.
Is SFTP secure?
Yes, when configured correctly. It encrypts data in transit, verifies the server’s identity, and supports strong authentication with SSH keys. Use SSH keys, strong passwords, verified host keys, and up-to-date software for the best protection.
What is the difference between SFTP and FTPS?
SFTP runs over SSH on port 22, while FTPS is FTP with TLS encryption added, usually on port 21. Both can be secure, but SFTP is simpler to set up and more firewall-friendly because it uses a single port, whereas FTPS needs extra ports and can fall back to plain FTP if misconfigured.
Conclusion
What is SFTP? It is the secure, modern way to move files between your computer and a server. Built on SSH, it encrypts your credentials and files, verifies the server you connect to, and works through a single firewall-friendly port, 22. Compared with FTP, which sends everything in plain text, and FTPS, which adds encryption to an older protocol, SFTP is simpler, safer, and easier to manage. If you transfer files that matter, switch to SFTP, use SSH keys where you can, and turn plain FTP off.



[…] have the same plain-text problem as POP3, which is why secure alternatives matter. See our guide to what SFTP is for the encrypted replacement for […]