Transfer files securely with sftp
Copy files to and from a server through the encrypted SSH File Transfer Protocol.
Run sftp user@host (optionally with :/remote/path to land in a directory), then use put/get to upload/download — add -r for whole folders.
01Command
Command
$ sftp user@example.com:/remote/path02What it does
sftp is the SSH way to move files: everything, including credentials and data, travels over the same encrypted channel as ssh, so there is no separate server to install. Inside the session, put file uploads, get file downloads, and put -r / get -r handle directories; ls, cd and pwd work like a normal shell. For one-shot transfers, sftp user@host <<< 'put file' or the batch flag -b avoids the interactive prompt.
03Risk
!Warning: sftp commands are not shell commands — you cannot pipe like sftp put file. Recursive transfers need -r on each put/get. If the server only offers FTP, sftp will not connect; that is a different, unencrypted protocol.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- sftp(1) - OpenBSD manual pagesEvidence: sftp is an interactive file transfer program over SSH; supports put/get, -r for recursive transfers, and connecting directly to a remote path.
- SFTP - ArchWikiEvidence: SFTP runs over SSH and provides secure file transfer; batch mode (-b) and chroot-restricted sftp accounts are documented.
Last verified: 2026-09-18 · Category: Security & Privacy