Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

SFTP

Direct answer

SFTP is the SSH file transfer protocol, served by sshd's sftp subsystem (internal-sftp) and used by sftp, scp in newer versions, and many GUI clients. It can be chrooted for file-only users.

When to use this

Use it for secure file transfer, or to give users file access without a shell.

First 30 seconds

1. sftp -v user@host — connects?

2. Subsystem configured: sshd -T | grep subsystem.

3. Chrooted user fails → chroot dir owned by root, not group/world-writable.

4. Server log for "bad ownership or modes for chroot directory".

5. Test upload into the writable subdirectory.

Operational verification

SSH session → sftp subsystem started → optional chroot → file operations

Evidence · next step

For SSH → SFTP, continue with the first unproven Topic check: Confirm effective Subsystem and Match/ChrootDirectory settings for the user. If that boundary is healthy, advance to the adjacent check: Correlate client SFTP error with sshd/session logs and filesystem permissions. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it for secure file transfer, or to give users file access without a shell.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

SSH transport/auth → subsystem request → sshd subsystem/chroot policy → SFTP protocol operation → filesystem authorization/storage → close/rename → file verification → consumer

Healthy evidence: the intended subsystem starts under the expected chroot/policy, required file operations succeed and resulting files meet content and metadata requirements.

Step 2 Verification and output interpretation Verify boundary

For tunneling/SFTP/SCP, verify the requested channel/subsystem after authentication rather than assuming login success shows every SSH feature.

Existing fast checks for this Topic. - Confirm effective Subsystem and Match/ChrootDirectory settings for the user.

  • Correlate client SFTP error with sshd/session logs and filesystem permissions.
  • Test the specific operation: list, read, create, write, rename or delete rather than generic login.
  • Verify uploaded/downloaded content and final path/ownership/permissions against acceptance criteria.

Verification chain. SSH transport/auth → subsystem request → sshd subsystem/chroot policy → SFTP protocol operation → filesystem authorization/storage → close/rename → file verification → consumer

Step 3 Commands Verify boundary
sftp user@host
sftp> put file
sftp> ls
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: authentication succeeds but subsystem is missing, chroot ownership rules fail, one operation works while rename/write is denied or transfer success is mistaken for consumer acceptance.

Step 5 Common mistakes Narrow the fault
  • Not restricting SFTP-only users (ChrootDirectory, ForceCommand internal-sftp).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

For file-only users use a Match block with ForceCommand internal-sftp and ChrootDirectory; the chroot directory must be owned by root and not writable by the user — give them a writable subdirectory.

Key checks
  • ssh -v user@host — client-side connection and authentication steps
  • journalctl -u ssh -u sshd -e — server log
  • sshd -T — effective server settings
  • ss -ltnp | grep :22 — sshd listening
ReferenceWhat it is1 section · depth on demand

Core model

After SSH transport/authentication, verify the server accepted the sftp subsystem and identify whether internal-sftp, external server, chroot or forced-command policy applies. Diagnose protocol operations against actual remote filesystem permissions and capacity.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

SFTP subsystem success shows protocol/file operations in its remote filesystem scope, but it does not show interactive shell availability, sudo rights or downstream processing.

In depth

sftp: interactive and batch file transfer

sftp is a file transfer client that speaks the SFTP protocol over SSH. The sftp(1) manual page describes it:

  • Commands: familiar names such as ls, cd, get, put, mkdir, rm, rename and chmod, with local counterparts lls, lcd and lmkdir, and !cmd for a local shell command.
  • Resuming: reget and reput resume interrupted transfers.
  • Batch mode: -b reads commands from a file and aborts on the first failure, unless a command is prefixed with -. A prefix of @ suppresses echoing.
  • Options: -r copies recursively but doesn't follow symbolic links, and -a resumes rather than overwrites. The manual warns that -a can give a corrupt result if the partial file differs from the source.
  • Tuning: -R sets the number of outstanding requests (default 64) and -B the buffer size (default 32768 bytes).

Useful commands

CommandPurpose
get -r dir / put -r dirRecursive transfer
reget file / reput fileResume
df -hFree space on the remote side
progressToggle the progress meter
lls, lcd, lpwdLocal equivalents
!ls -lRun a local shell command

A batch job that tolerates a missing directory

admin$ cat upload.batch
-mkdir incoming/2026-11-28
cd incoming/2026-11-28
put -p /srv/export/report-*.csv
@ls -l
admin$ sftp -b upload.batch -i ~/.ssh/id_ed25519_export upload1@files.example.net
sftp> -mkdir incoming/2026-11-28
sftp> cd incoming/2026-11-28
sftp> put -p /srv/export/report-*.csv
Uploading /srv/export/report-0001.csv to /incoming/2026-11-28/report-0001.csv
admin$ echo "exit=$?"
admin$ sftp sftp://upload1@files.example.net/outgoing/ack-2026-11-28.txt
admin$ sftp -R 128 -B 262144 srv1

Reading the batch file

The - before mkdir lets the job continue if the directory already exists. Without it, the whole batch would stop there. The @ before ls runs the command without echoing it. A failing put still aborts the job, which is the behaviour you want for automated transfers.

Chrooted SFTP users

On servers with ChrootDirectory and ForceCommand internal-sftp, users see the chroot as /. Paths in batch files must be relative to the chroot, not to the real filesystem.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Topic-specific state model. SFTP is the SSH File Transfer Protocol subsystem, a structured remote filesystem protocol carried in an SSH channel; it does not depend on an interactive shell but does depend on sshd subsystem configuration, authentication, chroot/path policy and filesystem authorization.

Interpretation rule. - Interactive shell denied ≠ SFTP must be denied; subsystem policy can differ.

  • SSH authentication success ≠ SFTP subsystem starts successfully.
  • SFTP directory listing works ≠ upload/rename/delete permissions are available.
  • Transfer complete ≠ consumer sees correct content/metadata or atomic publication semantics.

Quick reference

SFTP provides file transfer and remote file operations over SSH.

sftp -b batch.txt alice@web01           # scripted
sftp> put -r site/ /srv/www/
sftp> get /var/log/app.log
# chrooted SFTP-only users (sshd_config)
Subsystem sftp internal-sftp
Match Group sftp-only
    ChrootDirectory /srv/sftp/%u
    ForceCommand internal-sftp -l INFO
    AllowTcpForwarding no
    X11Forwarding no

The chroot directory must be owned by root and not writable by the user; give users a writable subdirectory inside it.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. SFTP subsystem success shows protocol/file operations in its remote filesystem scope, but it does not show interactive shell availability, sudo rights or downstream processing.

SFTP is an SSH subsystem and does not require the same server-side shell/file-copy path as legacy scp behavior.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. SFTP owns SSH subsystem file-transfer semantics. sshd_config owns Subsystem/Match/Chroot policy; Filesystem and Users/Permissions own the backing paths and access decisions.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in SSH → SFTP. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.openssh.com/manual.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
sftpssh file transferopenssh sftpinternal-sftp
Embedded reference data

Quick lookup tables

SFTP operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for SFTP.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateSFTP is the SSH File Transfer Protocol subsystem, a structured remote filesystem protocol carried in an SSH channel; it does not depend on an interactive shell but does depend on sshd subsystem configuration, authentication, chroot/path policy and filesystem authorization.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin exact client/server + attempt time → resolve destination/TCP path → inspect effective client config → identify OpenSSH versions → verify KEX + host-key trust → trace offered/accepted authentication → inspect effective sshd policy for user/source → verify session/subsystem/forward → verify remote process/filesystem/service → repeat original workload.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainSSH transport/auth → subsystem request → sshd subsystem/chroot policy → SFTP protocol operation → filesystem authorization/storage → close/rename → file verification → consumerTrace requested/configured state through effective state to the observed workload result.
Failure boundarySFTP subsystem success proves protocol/file operations in its remote filesystem scope; it does not prove interactive shell availability, sudo rights or downstream processing.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux SSH evidence can establish this proof path: SSH transport/auth → subsystem request → sshd subsystem/chroot policy → SFTP protocol operation → filesystem authorization/storage → close/rename → file verification → consumerUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured transport, trust, authentication, policy, session, filesystem or workload scope. SFTP subsystem success proves protocol/file operations in its remote filesystem scope; it does not prove interactive shell availability, sudo rights or downstream processing.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: correlate client and server evidence for the same attempt, inspect effective client/server configuration and identity/trust/authentication state, then test the exact requested session, transfer or forward before changing additional layers.Continue to the next unresolved boundary while preserving the original test condition.

SFTP · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundarySFTP
Topic pathSSH → SFTP
Runtime stateSFTP is the SSH File Transfer Protocol subsystem, a structured remote filesystem protocol carried in an SSH channel; it does not depend on an interactive shell but does depend on sshd subsystem configuration, authentication, chroot/path policy and filesystem authorization.
Fast checks- Confirm effective Subsystem and Match/ChrootDirectory settings for the user. - Correlate client SFTP error with sshd/session logs and filesystem permissions. - Test the specific operation: list, read, create, write, rename or delete rather than generic login. - Verify uploaded/downloaded content and final path/ownership/permissions against acceptance criteria.
Verification chainSSH transport/auth → subsystem request → sshd subsystem/chroot policy → SFTP protocol operation → filesystem authorization/storage → close/rename → file verification → consumer Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundarySFTP subsystem success proves protocol/file operations in its remote filesystem scope; it does not prove interactive shell availability, sudo rights or downstream processing. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?