How do I connect?
sftp ops@203.0.113.25 sftp -P 2207 -i ~/.ssh/ops_ed25519 ops@203.0.113.25 sftp chi-web # an alias from ~/.ssh/config
The login works exactly like ssh: same keys, same host check, same port. You land at an sftp> prompt in the remote user's home folder. Nothing needs installing on the server, because OpenSSH includes the SFTP subsystem on every image. Note the capital -P for the port, the same convention as scp.
How do I find my way around?
Every navigation command exists twice: plain for the remote side, with an l prefix for your local side.
sftp> pwd # remote folder sftp> lpwd # local folder sftp> cd /srv/exports sftp> lcd ~/Downloads sftp> ls -lh sftp> lls
Tab completion works for remote paths in the OpenSSH client, which makes browsing large trees quick. The complete command list is in SFTP commands reference.
How do I download and upload?
sftp> get orders-2026-11.csv sftp> get -r invoices/ ./invoices-backup/ sftp> put price-list.xlsx /srv/shared/ sftp> put -r ./build/ /srv/staging/build/ sftp> mget *.log
-r handles folders; -p keeps modification times and permissions. Wildcards work on the remote side for get and on the local side for put. Progress bars show speed and remaining time for each file.
What if a transfer breaks?
Resume instead of starting again:
sftp> reget vm-image.qcow2 sftp> reput dataset.tar.zst
Both check how much of the file already exists on the receiving side and continue from there. For multi-gigabyte files over long distances, for example from Phoenix to Amsterdam, this saves real time.
How do I script SFTP?
Write the commands in a file and pass it with -b. The session stops at the first failing command, unless a line starts with -:
# /usr/local/etc/push-reports.sftp cd /incoming lcd /var/reports/out put -p *.csv -rm processed/*.tmp bye
sftp -b /usr/local/etc/push-reports.sftp -i /root/.ssh/reports_ed25519 drop@198.51.100.12
Batch mode needs key authentication, since it cannot prompt for a password. Give the key its own account on the far side, ideally an SFTP-only, chrooted one as described in SFTP vs SSH. The exit status tells cron or systemd whether the run succeeded.
Which graphical clients work?
| System | Common free clients |
|---|---|
| Windows | WinSCP, FileZilla |
| macOS | Cyberduck, FileZilla |
| Linux desktop | File managers with sftp:// URLs, FileZilla |
Use the SFTP protocol option, port 22 or your custom port, and import your private key in the client's settings. Avoid saving passwords in clients on shared computers.
How do I end the session cleanly?
Type bye, exit or quit, or press Ctrl+D. Open file handles are closed and the SSH connection ends. If you need a quick shell command on your local side without leaving, prefix it with !, as in !ls -la.
When is another tool better?
For repeated syncs of whole folders, rsync sends only what changed; see Rsync over SSH. For one quick copy from the command line, scp is shorter; see The scp command. SFTP shines when you want to browse before choosing, or hand partners a familiar file-transfer login. The protocol itself is explained in What is SFTP?.
How do I keep transfers organized on the server?
Give each partner or job its own folder, such as /srv/drop/acme/incoming and /srv/drop/acme/outgoing, and let your own scripts move processed files to an archive. Uploads land as inbound traffic, which is free, so a drop box mostly costs disk space. Watch that space with df -h at the sftp prompt or a monitoring check, and clean archives on a schedule with find ... -mtime +90 -delete.
What should I check if a connection fails?
SFTP fails for the same reasons as SSH: wrong port, refused key, firewall rules. Run sftp -v to see where it stops, and compare with a plain ssh login to the same account. If ssh works but sftp disconnects immediately, the account is probably forced into a shell or chroot that is set up wrongly.
Keep Reading
SFTP commands reference
Every sftp prompt command worth knowing, grouped by job: navigation, transfers, resumes, file management, links, disk space and local escapes.
OpenWhat is SFTP?
The SSH File Transfer Protocol in plain terms: what it secures, how it compares with FTP, FTPS and SCP, and where it fits on a server.
OpenThe scp command
Copy files between machines with scp: ports, folders, preserved times, speed limits, jump hosts, remote-to-remote copies and when rsync is better.
OpenSFTP vs SSH
SFTP is a file transfer subsystem that rides inside SSH; learn when to hand someone SFTP only and how to jail them.
OpenFAQ
Quick Answers
Run sftp user@address, adding -P for a custom port and -i for a specific key.
Use put -r with the local folder and the remote destination.
Use reget with the file name; reput resumes uploads.
Yes. Write commands in a batch file and run sftp -b with key authentication.
WinSCP and FileZilla are common free choices that support keys.