Vol. I · No. 46The protocol sectionSat, 10 Oct 2026
Layer 7 · Transfer · file transfer inside an SSH session

SFTP

SSH File Transfer Protocol

SFTP is not FTP with encryption bolted on — it is a different protocol entirely, run as a subsystem inside an ordinary SSH connection. That gives it SSH’s authentication and encryption for free, over a single port that a firewall already understands.

SFTP is a file protocol carried inside SSH — one port, one authentication, encrypted from the first byte.

Operates at
Layer 7
an SSH subsystem
Port
22
the SSH port, only
Encryption
Inherited
from SSH
Relation to FTP
None
despite the name

How it works

A file channel opened inside an existing SSH connection
1 · SSH does the hard part
Key exchange, host-key verification and user authentication all happen first, exactly as for a shell.
By the time SFTP starts, the channel is already encrypted and both ends are identified.
2 · Open the sftp subsystem
The client requests a channel of type subsystem named sftp; the server starts its file-transfer server on it.
3 · Packet-based file operations
OPEN, READ, WRITE, STAT, RENAME, REMOVE — structured requests with a request id, not a text dialog. Resuming a transfer is just a READ at an offset.

Because it is a channel, SFTP multiplexes alongside a shell on the same connection — and because SSH already authenticated, there is no second login and no second port to open.

The main points

What SFTP does, step by step

1
Connect over SSH

The usual SSH handshake runs: key exchange, host key check, then user authentication by key or password.

2
Request the subsystem

The client opens a channel and asks for the sftp subsystem rather than a shell.

3
Exchange versioned packets

Both sides agree a protocol version, then work in binary request/response packets carrying a request id.

4
Operate on files

Handles are opened, read and written at explicit offsets — which is what makes resume and random access work.

Three things often confused
SFTP — a subsystem of SSH — this page
FTPS — the old FTP, wrapped in TLS
SCP — an older SSH copy, now deprecated

In cybersecurity

SFTP inherits everything SSH gets right — so its risks are mostly about what a legitimate account is allowed to reach once it is in.

Encrypted by default

There is no unencrypted mode; confidentiality and integrity come from the SSH transport.

Key-based access

Authorised keys work here as for a shell — and are equally easy to leave behind.

Chroot the users

Without a restricted directory an SFTP account can read wherever the OS permissions allow.

Disable the shell

An account meant only for files should not also grant an interactive login.

Host-key checking

The same first-connect fingerprint prompt is what stops a man-in-the-middle — don’t train users past it.

One port to guard

Everything is on 22, which makes the firewall simple and the brute-force target obvious.

Rides in the stack

IPTCPSSHSFTP

It is a channel inside SSH, not a protocol beside it — which is why it needs no port or credentials of its own.

Works with

SSHFTP

See it on Linux

scp

FTP or SFTP?

FTPSFTP
Ports21 + a data port22 only
CredentialsPlaintextEncrypted
DataPlaintextEncrypted
FirewallsNeeds a helperOne rule