scp, SFTP is more interactive and feature-rich, offering directory listings, resume support, and both remote and local command variants.
SFTP (part of the SSH suite) encrypts both authentication and data, protecting credentials and file contents while in transit.
Starting an SFTP session
To begin an interactive SFTP session from a client machine:sftp> prompt. Type help or ? to list available commands. Commands prefixed with l operate on the local machine (for example, lls, lcd, lpwd), while commands without the l operate on the remote host (for example, ls, cd, pwd).
Quick reference: common SFTP commands
Interactive help and local vs remote commands
Example short help output inside an SFTP session:Demo: preparing files locally and remotely
Create a local demo directory and two files on the control machine:node1) create a target directory and two remote files:
Interactive SFTP session: navigate, upload, and download
Connect from the control node to the remote node using SFTP:file1 and file2 to the remote incoming directory:
incoming1 and incoming2 to the local directory:
Non-interactive, one-liner transfers
SFTP also supports non-interactive one-liners to fetch or push a single file without entering the interactive prompt. Example: download a remote file directly into your local home directory:~, and exits immediately.
To transfer entire directories, use the
-r option with put or get (for example, put -r my_photos/ or get -r /remote/path/).Recap and next steps
- SFTP is an SSH-based secure file transfer tool that supports interactive and non-interactive workflows.
- Use
putto upload andgetto download. Prefix commands withlto operate on the local machine (e.g.,lls,lpwd). - For directories, use
-rto transfer recursively. - Use one-liners to script single file transfers, or open an interactive session for multi-step operations.
- OpenSSH SFTP documentation: https://www.openssh.com/manual.html
- SSH overview and best practices: https://www.ssh.com/academy/ssh