sftp
Secure interactive file transfer over SSH
TLDR
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")
CONFIGURATION
~/.ssh/config
SSH client configuration file; settings like Host aliases, IdentityFile, ProxyJump, and Port apply to sftp connections.~/.ssh/known_hosts
Database of accepted server host keys, shared with ssh and scp./etc/ssh/ssh_config
System-wide SSH client configuration applied to all users.
INTERACTIVE COMMANDS
ls [path]: List remote directorylls [path]: List local directorycd path: Change remote directorylcd path: Change local directorypwd: Print remote working directorylpwd: Print local working directoryget [-r] remote [local]: Download file/directoryput [-r] local [remote]: Upload file/directorymkdir path: Create remote directoryrmdir path: Remove remote directoryrm file: Delete remote filerename old new: Rename remote filechmod mode file: Change remote file permissionschown uid file: Change remote file owner! command: Execute local shell commandexit 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.
