SFTP is often used to transfer files in addition to usual shell access in SSH, by generic users. In some scenarios, is possible to use OpenSSH SFTP server as a pure file transfer service to replace the traditional FTP service
/etc/ssh/sshd_config), adding followings:Match Group ftp ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding no X11Forwarding no PermitTTY no PermitTunnel no
The above configuration mean for every users with ftp group logging from SSH, chroot(2) the session processes to their home directory, and allowing only SFTP session. If you need to use public key authentication method for SFTP users, add
AuthorizedKeysFile /etc/ssh/ftp_authorized_keys.%u
and add public keys in /etc/ssh/ftp_authorized_keys.<user-name>.
Since file transfer usually uses large amount traffic through the SSH server sshd(8); it may be desirable to switch to the High-performance SSH for sshd(8). High-performance SSH is a fork of OpenSSH that use dynamic transfer buffer size and multi-threading AES-CTR cipher implementation to improve data transfer performance for SSH. Refer to its website on how to install and tune this implementation.