NOC online · 24/7Longview, TX · +1 323 412 0665
KinetikatechServers · Security · Websites
EN

Linux Commands & Shell Skills

sftp: File Transfer on an SSH Budget

sftp rides inside SSH, which is exactly why it outlived its peers: keys, chroots, jump hosts, and the audit trail all come along for free. OpenSSH quietly moved scp onto the SFTP protocol at version 9.0 because SFTP plays a real protocol's role: directory listing, mkdir, permissions, renames, and far fewer protocol surprises. Interactive sftp is fine for one-off moves; automation runs through batch mode, exit codes, and the occasional apology to rsync.

Key points

  1. Automation is batch mode: sftp -b batch.txt user@host runs a file of commands, exits nonzero on any failure, and reads from stdin with -b -; unattended password prompts are the bug batch mode removes twice as fast as it adds safety.
  2. The command set is small on purpose: ls -l, mkdir, put -p (preserve timestamps), get -r (recursive), chmod, and df -h inside the session cover 95% of operational needs.
  3. Know when rsync wins: sftp re-sends whole files, while rsync -avz --partial over ssh moves deltas, prunes nothing silently, and preserves the metadata bulk archives actually care about.
  4. Server-side, sftp is a fence: ForceCommand internal-sftp inside a Match block with ChrootDirectory turns an account into an encrypted, audited drop box with no shell at all.
  5. 'sftp works, shell does not' is the design, not a bug: the Subsystem sftp internal-sftp line is what enables it, and scp's move onto SFTP in OpenSSH 9.0 means legacy servers without the subsystem can break old scp jobs.
  6. Cron use is judged on failure behavior: -o BatchMode=yes, -o ConnectTimeout=10, and an explicit exit-code check turn silent hangs into loud, pageable failures.
  7. Progress output is noise control: sftp is chatty, cron logs are quiet; -q (or redirects) plus logging at the sshd side gives you an audit trail that does not rot into gigabytes of transfer bars.
  8. The one typo that careers are made of: sftp -P 2222 takes a capital P (lowercase -p means preserve), while scp swapped conventions on the same letters; when a port is wrong, check the case first.

Field note

A cron sftp job once hung six hours on an unexpected password prompt before anyone noticed. Every scripted transfer since gets -b, -o BatchMode=yes, and an exit-code check that pages instead of waits.

Frequently asked questions

Did OpenSSH 9.0 really change scp?

The protocol, not the surface: scp now moves files over SFTP underneath, so hosts without an sftp subsystem silently break legacy scp jobs; the fix is enabling the subsystem, not reverting habits.

Can I move a single file without sftp at all?

Yes: cat bigfile.bin | ssh user@host 'cat > /tmp/bigfile.bin' is the portable one-pipe transfer; no resume, no metadata, but it works anywhere SSH works, which is exactly its use case.

Is sftp slower than scp or rsync?

Sometimes: per-file protocol overhead and default buffering show up in bulk directory trees; measure on your link before optimizing, and remember rsync usually answers when the complaint is 'too slow'.

How do I give a third party uploads without shell access?

A dedicated account with ChrootDirectory, ForceCommand internal-sftp, and a writable subdir; keys, jail, timeout, and log review included, that is a drop box rather than an invitation.

How Kinetikatech helps with linux commands & shell skills

Honestly, most teams come to us after trying it themselves first: The commands and scripting habits that decide whether an administrator operates a server or fights it: search, transform, transfer, and supervise text and processes with the tools that live in every base install. Our Linux Server Security and Server Management service exists so you don't have to learn linux commands & shell skills the hard way, we handle the setup, the watching, and the 3 a.m. surprises.

Talk to an engineer

Server problem? Hacked site? Slow website?

Critical issues answered within 30 minutes, 24 hours a day, 7 days a week.

Request Emergency Support support@kinetikatech.com