How-to

SFTP vs SSH: Same Tunnel, Different Jobs

SFTP is not a separate server; it is a file protocol carried inside an SSH connection. The difference that matters is what you let each account do once connected.

Are SFTP and SSH different protocols?

SSH is the secure transport: it encrypts the connection and authenticates both sides. SFTP, the SSH File Transfer Protocol, is one service that runs inside that transport, alongside interactive shells, single commands and port forwarding. When you run sftp, your client opens an ordinary SSH connection and asks the server to start the sftp subsystem instead of a shell. Same port, same keys, same encryption.

That also means SFTP has nothing to do with FTP or FTPS. FTP is a separate, older protocol with its own ports and plain-text logins; FTPS is FTP wrapped in TLS. SFTP needs no extra daemon on your machine, because OpenSSH already provides it.

How do they compare in practice?

QuestionSSH shell accessSFTP-only access
Can the user run commands?YesNo
Can they upload and download?Yes, with scp, sftp or rsyncYes, with any SFTP client
Can they see the whole file system?Whatever permissions allowOnly the jail, if chrooted
Port and keys22, SSH keysThe same
Typical userAdmins, developersClients, designers, partners

What happened to scp?

Since OpenSSH 9.0, released in 2022, the scp command uses the SFTP protocol under the hood by default. The old scp protocol had design flaws around file name handling, so the switch made scp safer without changing how you type it. If you ever need the legacy behavior for an ancient server, scp -O brings it back. For large or repeated copies, rsync over SSH is usually the better tool because it only sends what changed; see Rsync over SSH.

When should I give someone SFTP only?

Whenever a person or system needs to move files but has no reason to run commands: an agency uploading site assets, a partner dropping nightly CSV exports, a scanner pushing PDFs. Shell access lets a user read configuration files, run code and explore other accounts within the limits of permissions. An SFTP jail shrinks all of that to one folder.

How do I create a chrooted SFTP-only account?

Use OpenSSH's built-in internal-sftp server and a Match block. The chroot directory and every folder above it must be owned by root and not writable by anyone else, or sshd refuses the login. Give the user a writable subfolder inside it:

groupadd sftpdrop
mkdir -p /srv/drop/acme/incoming
chown root:root /srv/drop /srv/drop/acme
chmod 755 /srv/drop /srv/drop/acme
useradd -g sftpdrop -d /incoming -s /usr/sbin/nologin acme
chown acme:sftpdrop /srv/drop/acme/incoming

Then add the rule in a drop-in file, for example /etc/ssh/sshd_config.d/40-sftpdrop.conf:

Match Group sftpdrop
    ChrootDirectory /srv/drop/%u
    ForceCommand internal-sftp -d /incoming
    AllowTcpForwarding no
    X11Forwarding no
    PermitTTY no

Make sure the main Subsystem sftp line exists in sshd_config; the stock files on every image already have it. Check with sshd -t and reload the service. On Enterprise Linux images use /sbin/nologin as the shell path, and run restorecon -Rv /srv/drop so SELinux labels match.

How does the partner log in?

With keys, ideally. Place their public key in a root-managed location, for example by adding AuthorizedKeysFile /etc/ssh/keys/%u to the Match block and creating /etc/ssh/keys/acme, since their home directory is inside the jail. Then they connect with any client: sftp acme@203.0.113.25, FileZilla, WinSCP or Cyberduck. An attempt to open a shell with ssh is refused with the message that the server only accepts SFTP.

Do partner uploads eat into the monthly traffic?

Files that partners upload arrive as inbound traffic, which is free. Downloads leave your machine and count toward the monthly 15 TB of outgoing traffic, or 5 TB in Singapore. A drop box that mostly receives data barely touches the allowance.

Keep Reading

Rsync over SSH

Copy and mirror folders between machines with rsync over SSH: trailing slashes, dry runs, custom ports, sudo on the far side and bandwidth caps.

Open

Everyday SSH commands

The SSH toolkit you will actually use on a server: ssh, ssh-keygen, ssh-copy-id, ssh-agent, scp, sftp, ssh-keyscan and tunnels.

Open

What is SSH?

The protocol behind every remote login to a Linux box: what it protects, where it came from and what you use it for daily.

Open

Storage servers

From 8 TB mirrors to a six-drive NVMe array of more than 90 TB raw, with ZFS or mdadm laid out by you.

Open

FAQ

Quick Answers

No. SFTP is its own protocol carried inside SSH. FTP and FTPS are separate protocols with their own ports.

No. OpenSSH includes it, and every image we install has it enabled.

Yes. Force internal-sftp with a Match block and set a nologin shell; a ChrootDirectory also limits what they can see.

The chroot folder or a parent folder is not owned by root or is writable by others. Fix ownership and modes and try again.

Yes. Since OpenSSH 9.0 it uses the SFTP protocol by default; scp -O restores the legacy mode if a very old server needs it.