Strovent SystemsSign in
Reference

SFTP

What SFTP is, how it differs from FTP, FTPS and SCP, and what the host must allow.

SFTP is the SSH File Transfer Protocol. It runs as a subsystem inside an SSH connection, so it uses the same login, the same keys and the same encryption as SSH.

Not the same as

  • FTP. An older protocol that sends passwords in clear text and uses extra connections.
  • FTPS. FTP over TLS. Different protocol, different port, different server.
  • SCP. An older SSH copy tool. Modern OpenSSH runs it over SFTP. It has no directory listing.

SFTP has nothing to do with FTP apart from the name.

What the host needs

  • SSH access for the account.
  • The sshd_config line Subsystem sftp ... (usually /usr/lib/openssh/sftp-server or internal-sftp). Without it the host closes the session.
  • Permission on the folders. SFTP follows the file system permissions of the account.

Some hosts limit a user to one folder (a chroot, ChrootDirectory) with internal-sftp. Paths inside it start at /. If the login closes at once and the server log says "bad ownership or modes for chroot directory", see SFTP chroot: bad ownership or modes for chroot directory. If the account's login shell is nologin, an external SFTP server is blocked too and SSH prints This account is currently not available.; internal-sftp can still work. See SSH "This account is currently not available" (nologin shell).

Common commands (command line client)

ls, cd, pwd          list and change folders
get file             download
put file             upload
mkdir, rm, rmdir     create and delete
rename old new
chmod 640 file       change permissions

To copy a whole folder, see sftp put -r: copy a whole folder, and "Couldn't canonicalize".

What a good client does

  • Shows folders, sizes and dates, and lets you upload, download, rename and delete.
  • Resumes an interrupted transfer when the server supports it.
  • Keeps the transfer running while the app is in the background, if the platform allows it.

Common problems

Spotted a mistake? Email [email protected].