C.W.K.
Stream
Lesson 02 of 12 · published

SFTP

~12 min · sftp, interactive, ftp-like

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

SSH's interactive file browser

sftp gives you an FTP-like interactive session over SSH. You connect once and then navigate the remote filesystem with familiar shell commands: ls, cd, get, put. Useful when you want to browse rather than know the exact path you're after.

Local vs remote commands

Inside an sftp session, commands without a prefix operate on the remote side. Commands prefixed with l (lls, lcd, lpwd) operate on the local side. get downloads, put uploads. Tab completion works on both sides.

GUI clients use this protocol

Cyberduck, Transmit, FileZilla all speak SFTP. Configure them with your SSH host (and optionally your ~/.ssh/config alias) and they treat the remote filesystem like a local Finder window. Same auth as your SSH config.

Code

SFTP basics·bash
# Connect via host alias from ~/.ssh/config
sftp office

# Inside the sftp session
sftp> ls           # remote listing
sftp> lls          # local listing
sftp> cd /var/log  # navigate remote
sftp> lcd /tmp     # navigate local
sftp> get system.log         # download to local cwd
sftp> put report.pdf         # upload from local cwd
sftp> mkdir backup
sftp> rm old.log
sftp> bye          # exit

External links

Exercise

Run sftp to a host you have access to. Navigate to a directory with several files, list them, download one with get, then upload a different file with put. Switch between local (lls/lcd) and remote (ls/cd) deliberately. Exit with bye. SFTP is the answer when you don't already know the exact path you want to grab — it's a navigable file browser, not a copy command.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.