sftp
TLDR
Connect to a remote server
SYNOPSIS
sftp [-P port] [-i identityfile] [user**@**]host[**:**path_]
DESCRIPTION
sftp is the SSH File Transfer Protocol client, providing secure interactive file transfer over SSH connections. It offers a familiar FTP-like interface while using SSH for authentication and encryption.
Unlike FTP, SFTP encrypts all data including credentials and file contents. It uses a single connection (no separate data channel) making it firewall-friendly.
The interface supports both interactive use and batch mode (-b) for scripting. Tab completion works for both local and remote paths in most implementations.
SFTP can transfer binary and text files without mode switches and preserves file attributes like permissions and timestamps.
PARAMETERS
-P port
Connect to specified port (note: uppercase P, unlike ssh)-i identityfile_
Use specified private key file-b batchfile
Batch mode; read commands from file-C
Enable compression-r
Recursively copy directories (with get/put)-v
Verbose mode-o option
Pass option to SSH (e.g., -o "ProxyJump=jump-host")
INTERACTIVE COMMANDS
ls [path]: List remote directory
lls [path]: List local directory
cd path: Change remote directory
lcd path: Change local directory
pwd: Print remote working directory
lpwd: Print local working directory
get [-r] remote [local]: Download file/directory
put [-r] local [remote]: Upload file/directory
mkdir path: Create remote directory
rmdir path: Remove remote directory
rm file: Delete remote file
rename old new: Rename remote file
chmod mode file: Change remote file permissions
chown uid file: Change remote file owner
! command: Execute local shell command
exit or quit: Close connection
CAVEATS
Port is specified with uppercase -P, not lowercase -p like SSH. This is a common source of confusion.
SFTP is different from FTPS (FTP over SSL/TLS). SFTP uses SSH; FTPS uses the FTP protocol with TLS encryption.
For automated transfers, use batch mode (-b) or consider rsync over SSH for more sophisticated synchronization.
Symbolic links are followed by default. Use get -P or put -P to preserve symlinks as symlinks.


