SFTP Command Reference
Every command for the OpenSSH sftp client with syntax and examples - connecting, browsing, transferring, permissions, and batch scripting. Works identically on Windows 10/11, macOS, and Linux, which all ship the OpenSSH client.
Updated July 2026
Connecting to a server
SFTP runs over SSH (port 22 by default), so authentication and host-key verification work exactly like ssh. These flags go on the command line before the session starts:
| Command / flag | What it does | Example |
|---|---|---|
sftp user@host | Start an interactive SFTP session. | sftp alice@example.com |
-P port | Connect to a non-standard port (note: capital P, unlike ssh). | sftp -P 2222 alice@example.com |
-i keyfile | Authenticate with a specific SSH private key. | sftp -i ~/.ssh/deploy_key alice@example.com |
-b file | Batch mode - run commands from a file non-interactively. | sftp -b upload.txt alice@example.com |
-r | Make get/put recursive for the whole session. | sftp -r alice@example.com |
sftp user@host:path | Fetch a file directly and exit (no interactive session). | sftp alice@example.com:/logs/app.log |
If the connection is refused or hangs, verify the server first with the SFTP Connection Tester, and check which authentication methods it accepts with the SFTP Auth Method Checker.
Downloading & uploading
| Command | What it does | Example |
|---|---|---|
get | Download a file from the server. | get report.pdf |
get -r | Download a directory and everything in it. | get -r backups |
put | Upload a local file to the server. | put site.zip |
put -r | Upload a directory recursively. | put -r dist |
mget | Download multiple files matching a pattern. | mget *.log |
mput | Upload multiple files matching a pattern. | mput *.html |
reget | Resume a partially downloaded file. | reget big-backup.tar |
reput | Resume a partially uploaded file. | reput big-backup.tar |
progress | Toggle the transfer progress meter on/off. | progress |
There is no ascii/binary toggle - SFTP always transfers files byte-for-byte, so nothing gets corrupted by line-ending conversion.
Batch mode & scripting
For unattended transfers, put commands in a file (one per line) and run sftp in batch mode. Batch mode aborts on the first error and requires key-based authentication - it cannot prompt for a password:
# upload.txt cd /var/www/site lcd C:\Projects\site\dist put -r . bye C:\> sftp -b upload.txt -i C:\keys\deploy_key deploy@example.com
This works, but every recurring job means maintaining a script, a key, and a Task Scheduler entry. If you'd rather define "upload this folder every night at 2:00" in a UI - with retries, notifications, and history - that's what FTPie's Scheduled Transfers do.
About SFTP commands
SFTP (SSH File Transfer Protocol) is not FTP-over-SSH - it is a separate protocol built on the SSH connection layer, defined in the IETF draft-ietf-secsh-filexfer series. The sftp command in Windows, macOS, and Linux is the OpenSSH client implementation, and its command set is what this page documents. Because everything runs inside SSH, one open port (22) carries authentication, commands, and encrypted data - no passive-mode port ranges or TLS certificates to configure.
Coming from classic FTP? The command sets overlap but differ in important ways - see the FTP Command Reference for the ftp.exe and RFC 959 protocol commands.
Common questions
No. SFTP is a different protocol that runs over SSH, and its command set is similar but not identical. Core commands like get, put, cd, ls, and bye work in both, but SFTP adds Unix-style commands such as chmod, ln, and df, uses reget/reput for resuming transfers, and has no ascii/binary mode - every transfer is binary. Commands like mdelete, hash, or literal from classic FTP clients do not exist in sftp.
Use the -r (recursive) flag: get -r projectfolder downloads a whole directory tree, and put -r projectfolder uploads one. The target directory must not already contain conflicting files. You can also start the session with sftp -r user@host to make transfers recursive by default.
Use reget filename to resume a partially downloaded file and reput filename to resume an upload. The partial file must still exist on the receiving side; sftp continues from where it stopped instead of starting over.
Yes. Windows 10 (1809 and later) and Windows 11 ship the OpenSSH client, so you can run sftp user@host directly from Command Prompt or PowerShell - no extra software needed. The same commands listed on this page work identically on Windows, macOS, and Linux.
Put one command per line in a text file and run sftp -b batch.txt user@host. Batch mode requires non-interactive authentication, which in practice means setting up SSH key authentication first. For recurring jobs - scheduled uploads, backups, syncs - a client with a built-in scheduler saves you from maintaining scripts and Task Scheduler entries.
Prefer a visual SFTP client?
FTPie is a modern SFTP client for Windows with SSH key authentication, host-key verification, drag-and-drop recursive transfers, and a built-in scheduler - free for up to 3 server connections.
Download FTPie Free