sftp(1)
Interactive secure file transfer program using SSH.
Synopsis
sftp [OPTION]... [USER@]HOST[:PATH]Description
sftp is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted SSH transport. It connects and logs in to the specified HOST, optionally at a specific remote directory. Once connected, the user is presented with an sftp> prompt where commands can be entered to navigate, list, and transfer files.
sftp is more secure than traditional ftp since all traffic, including passwords, is encrypted. It uses the same authentication methods as ssh (public key, password) and can reuse existing ssh configurations.
Common options
| Flag | What it does |
|---|---|
-P port | Specify the port to connect to on the remote host (default: 22) |
-C | Enable compression of data in transit |
-o option | Pass ssh options to the underlying ssh connection (e.g., -o StrictHostKeyChecking=no) |
-b batchfile | Read commands from a batch file instead of stdin; useful for automation |
-v | Increase verbosity for debugging connection and protocol issues |
-i identity_file | Specify private key file for authentication |
-4 | Force IPv4 connections only |
-6 | Force IPv6 connections only |
Examples
Connect to example.com as 'user' and enter interactive sftp shell
sftp user@example.comConnect to a non-standard SSH port (2222)
sftp -P 2222 admin@192.168.1.100Execute sftp commands from a batch file without interactive prompt
sftp -b commands.txt user@example.comUse a specific private key file for authentication
sftp -i ~/.ssh/id_ed25519 deploy@server.comConnect and automatically change to remote directory /home/user/files
sftp user@example.com:/home/user/filesConnect with compression enabled for slower connections
sftp -C user@example.com