What is SFTP (SSH File Transfer Protocol)?
Learn what SFTP is, how it secures file transfer over SSH, and how it differs from FTP and FTPS — with networking interview Q&A.
Expected Interview Answer
SFTP (SSH File Transfer Protocol) is a secure file transfer protocol that runs entirely over a single encrypted SSH connection on port 22, providing file operations like upload, download, and directory listing without ever sending credentials or data in cleartext.
Unlike FTP, SFTP is not FTP-over-TLS; it is a completely different protocol built as a subsystem of SSH, reusing SSH’s existing authentication (password or public key) and encrypted channel. Because everything, commands and file data alike, travels over one already-established, already-encrypted connection, SFTP avoids the dual-connection complexity and firewall friction that plagues classic FTP’s active/passive modes. SFTP also supports richer file operations such as resuming interrupted transfers, setting permissions, and following symbolic links, all authenticated and encrypted end to end. Because it rides on SSH, any server that already exposes SSH access can support SFTP with no extra open ports.
- Encrypts both authentication and file data over a single SSH channel
- No separate data connection, simplifying firewall and NAT traversal
- Supports permissions, resuming transfers, and richer file metadata
- Reuses existing SSH key-based authentication infrastructure
AI Mentor Explanation
SFTP is like a single armored van that carries both the coach’s instructions and the actual kit bags together, sealed and guarded the entire trip, instead of shouting instructions over an open radio and sending kit separately by an unguarded truck. Because everything rides in one sealed vehicle, nobody outside can intercept either the plan or the equipment. This mirrors how SFTP tunnels both commands and file data through one encrypted SSH connection instead of FTP’s separate, unencrypted control and data channels.
Step-by-Step Explanation
Step 1
SSH handshake
The client establishes an encrypted SSH connection to the server on port 22, negotiating keys.
Step 2
Authentication
The client authenticates via password or public key over the same encrypted channel.
Step 3
SFTP subsystem
An SFTP subsystem is started inside the SSH session to handle file operation requests.
Step 4
Encrypted transfer
All commands and file data flow through the single encrypted SSH channel, no second connection needed.
What Interviewer Expects
- Knows SFTP is an SSH subsystem, not FTP-over-TLS
- Explains that everything travels over one encrypted connection on port 22
- Can contrast SFTP with FTP and FTPS
- Understands SFTP reuses SSH key-based authentication
Common Mistakes
- Confusing SFTP with FTPS (FTP over TLS) — they are different protocols
- Thinking SFTP still uses separate control and data connections like FTP
- Assuming SFTP requires a different port than SSH
- Not knowing SFTP supports resuming interrupted transfers
Best Answer (HR Friendly)
“SFTP is the secure way to move files between machines — it works over the same encrypted SSH connection people use to log into servers, so both the login and the files themselves are protected the whole way. It is different from plain FTP or even FTPS, and it is the go-to choice whenever a company needs to move sensitive files safely.”
Code Example
# Connect via SFTP (uses SSH port 22)
sftp user@example.com
# Inside the SFTP prompt:
sftp> ls
sftp> get report.csv
sftp> put upload.txt
sftp> exit
# Non-interactive copy with scp-like syntax (also SSH-based)
sftp user@example.com <<'CMDS'
get remote_file.txt local_file.txt
CMDSFollow-up Questions
- How does SFTP differ from FTPS (FTP over TLS)?
- Why does SFTP not need separate active/passive data connections?
- How does public-key authentication work for SFTP access?
- What happens to an SFTP transfer if the SSH connection drops mid-file?
MCQ Practice
1. What underlying protocol does SFTP run over?
SFTP is a subsystem of SSH, reusing its encrypted channel and authentication.
2. What port does SFTP typically use?
SFTP uses port 22, the same port as standard SSH connections.
3. How does SFTP compare to plain FTP in terms of connections?
SFTP sends both commands and file data over a single already-encrypted SSH connection.
Flash Cards
What is SFTP? — A secure file transfer protocol running as an SSH subsystem over port 22.
Is SFTP the same as FTPS? — No — SFTP is SSH-based; FTPS is FTP with TLS added. They are different protocols.
How many connections does SFTP use? — One encrypted SSH connection for both commands and file data.
How does SFTP authenticate? — Via SSH authentication methods, typically password or public key.