Use it for secure file transfer, or to give users file access without a shell.
SFTP
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.
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.
SSH session → sftp subsystem started → optional chroot → file operations
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
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
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.
ssh -v user@host— client-side connection and authentication stepsjournalctl -u ssh -u sshd -e— server logsshd -T— effective server settingsss -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,renameandchmod, with local counterpartslls,lcdandlmkdir, and!cmdfor a local shell command. - Resuming:
regetandreputresume interrupted transfers. - Batch mode:
-breads commands from a file and aborts on the first failure, unless a command is prefixed with-. A prefix of@suppresses echoing. - Options:
-rcopies recursively but doesn't follow symbolic links, and-aresumes rather than overwrites. The manual warns that-acan give a corrupt result if the partial file differs from the source. - Tuning:
-Rsets the number of outstanding requests (default 64) and-Bthe buffer size (default 32768 bytes).
Useful commands
| Command | Purpose |
|---|---|
get -r dir / put -r dir | Recursive transfer |
reget file / reput file | Resume |
df -h | Free space on the remote side |
progress | Toggle the progress meter |
lls, lcd, lpwd | Local equivalents |
!ls -l | Run 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.
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.
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
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%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.
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.
Quick lookup tables
SFTP operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for SFTP.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | 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. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin 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 chain | SSH transport/auth → subsystem request → sshd subsystem/chroot policy → SFTP protocol operation → filesystem authorization/storage → close/rename → file verification → consumer | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | SFTP 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 evidence | Correlated 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 → consumer | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It 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 check | Continue 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 boundary | SFTP |
|---|---|
| Topic path | SSH → SFTP |
| Runtime state | 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. |
| 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 chain | SSH 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 boundary | SFTP 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 rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |