sftp — File transfer over SSH
Linux / Remote server connection management / sftp.html
An interactive file transfer client that runs over an SSH connection.
Basic Information
| Command Name | sftp |
|---|---|
| One-line Introduction | An interactive file transfer client that runs over an SSH connection. |
| Provided by | OpenSSH (openssh-client) |
| Official Documentation | https://man.openbsd.org/sftp.1 |
| Supported Operating Systems | Linux, macOS, BSD, WSL |
| Installation Status | Installed by default (openssh-client) |
| Category | Linux remote access (tags: Remote access and file transfer (tags: sftp, ssh, transfer, upload, download)) |
What is this command?
sftp is an interactive file transfer client that runs inside SSH. It offers FTP-like commands such as get, put, ls and cd, but every byte travels through the encrypted channel and reuses existing keys and accounts.
Where scp copies one path per invocation, sftp keeps a session open so you can move around and transfer many files. Batch mode (-b) supports non-interactive use.
What problems does it solve?
- Uploading configuration files or build artifacts to a remote server
- Browsing a remote tree and downloading only what you need
- Environments where only SSH port 22 is open
- Automating repeated transfers with key-based authentication
Key features
Interactive transfer
After connecting, use cd, ls, get and put across local and remote paths.
- When to use: Handling several files in one session
- What you get: You can inspect the layout while working.
- Limitations: A wrong path can place files elsewhere.
Batch mode
The -b option reads a command file and runs it without prompts.
- When to use: Scheduled or CI-driven transfers of known files
- What you get: The same transfer repeats unattended.
- Limitations: A failure aborts the batch, so check exit codes.
Reusing SSH keys
It honors ~/.ssh/config, keys and ProxyJump settings.
- When to use: When SSH already works and only files must move
- What you get: No extra account or port is needed.
- Limitations: If SSH is blocked, sftp cannot be used.
Installation and usage
Check whether it is installed
sftp -V
sudo apt install openssh-client # Debian/Ubuntu sudo dnf install openssh-clients # Fedora
Real-world examples
Connect and browse
Connect, then check the working directory and list files.
sftp deploy@203.0.113.10
pwd
ls -l
bye
Upload and download
Put a local file and fetch a remote one.
put ./app.tar.gz /srv/releases/
get /var/log/app/error.log ./error.log
Batch transfer
Run a command list without interaction.
printf 'put build.zip /srv/www/\nbye\n' > /tmp/up.txt
sftp -b /tmp/up.txt deploy@203.0.113.10