When to use sftp
Use sftp when you want an interactive file-transfer session through SSH. Its remote filesystem context differs from the client's local context, so verify both sides before uploading or downloading data.
Syntax
sftp [PARAMETERS] [USER@]NODESquare brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Open file session
sftp deploy@server.example.comAn authenticated transfer prompt opens if the SSH account and SFTP subsystem are available.
Connect on a different port
sftp -P 2222 deploy@server.example.comThe connection uses the specified nondefault port.
Run a prepared batch file
sftp -b ./transfer.sftp deploy@server.example.comCommands are read from a prepared batch file; its contents and authentication must be suitable for unattended use.
Notes and limitations
- In an interactive session, ls and pwd refer to the server; lls and lpwd refer to the local client. get copies files from the server to the local client. put copies files from the local client to the server.
- SFTP runs over SSH; it is not FTP over TLS. Configure secure non-interactive authentication before using batch mode.
Common questions and troubleshooting
How do local and remote directories differ in sftp?
Remote directory commands affect the server view; local directory commands affect the machine running the client. Check both locations before a transfer.
Why can SSH work while sftp is rejected?
The server may disable or restrict its SFTP subsystem, or the account may have a different permitted environment. Check server policy and the exact error.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man sftp.