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.com

Inspect local/remote locations, upload, download under a new name, then exit.

pwd
lpwd
ls
put report.txt
get report.txt report-downloaded.txt
bye

Options and examples

-P portCommon

Connect to the specified SSH port using uppercase P.

Example
sftp -P 2222 alice@server.example.com
-i identity_fileCommon

Use the specified private key for authentication.

Example
sftp -i ~/.ssh/id_ed25519 alice@server.example.com
-J destination

Connect through the specified SSH jump host.

Example
sftp -J alice@bastion.example.com alice@internal.example.com
-b batchfile

Read SFTP commands from a batch file. Arrange authentication without an interactive prompt.

Example
sftp -b transfer.txt alice@server.example.com
-o option

Pass an SSH client configuration option.

Example
sftp -o ConnectTimeout=10 alice@server.example.com
-C

Request SSH compression.

Example
sftp -C alice@server.example.com
-v

Show connection diagnostics; output can contain sensitive details.

Example
sftp -v alice@server.example.com
get / putCommon

At the SFTP prompt, download or upload a file. These are interactive commands, not shell commands.

Example
get report.txt report-downloaded.txt
put report.txt
ls / cd / pwdCommon

At the SFTP prompt, list files, change the remote directory, or show the remote directory.

Example
ls
cd reports
pwd
lcd / lpwd / bye

At the SFTP prompt, change or show the local directory, or close the session.

Example
lcd ~/Downloads
lpwd
bye

Authoritative references

Reviewed October 27, 2026