Transfer files securely with sftp

Copy files to and from a server through the encrypted SSH File Transfer Protocol.

LinuxsshtransfersftpcliLow risk
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/path

02What 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

RiskLow risk
RequirementsSSH access to the remote host; sftp client (part of openssh-client).
!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 pages
    man7.org · community · 2026-09-17
    Evidence: sftp is an interactive file transfer program over SSH; supports put/get, -r for recursive transfers, and connecting directly to a remote path.
  • SFTP - ArchWiki
    Arch Wiki · community · 2026-09-17
    Evidence: 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