sftp
Transfer files interactively over SSH.
Before you run
The server must provide the SFTP subsystem. Run the first example in your local shell; run the second block inside the sftp> prompt, without typing that prompt. pwd and ls refer to the server; lpwd refers to this computer. put uploads and get downloads; review destinations to avoid overwriting files.
Examples
Connect to the SFTP service on port 2222.
sftp -P 2222 alice@server.example.comInspect local/remote locations, upload, download under a new name, then exit.
pwd
lpwd
ls
put report.txt
get report.txt report-downloaded.txt
byeOptions and examples
-P portCommonConnect to the specified SSH port using uppercase P.
sftp -P 2222 alice@server.example.com-i identity_fileCommonUse the specified private key for authentication.
sftp -i ~/.ssh/id_ed25519 alice@server.example.com-J destinationConnect through the specified SSH jump host.
sftp -J alice@bastion.example.com alice@internal.example.com-b batchfileRead SFTP commands from a batch file. Arrange authentication without an interactive prompt.
sftp -b transfer.txt alice@server.example.com-o optionPass an SSH client configuration option.
sftp -o ConnectTimeout=10 alice@server.example.com-CRequest SSH compression.
sftp -C alice@server.example.com-vShow connection diagnostics; output can contain sensitive details.
sftp -v alice@server.example.comget / putCommonAt the SFTP prompt, download or upload a file. These are interactive commands, not shell commands.
get report.txt report-downloaded.txt
put report.txtls / cd / pwdCommonAt the SFTP prompt, list files, change the remote directory, or show the remote directory.
ls
cd reports
pwdlcd / lpwd / byeAt the SFTP prompt, change or show the local directory, or close the session.
lcd ~/Downloads
lpwd
byeAuthoritative references
Reviewed October 27, 2026