Learn How to setup SFTP server on Ubuntu 18.04 LTS.
Requirements
The below SFTP configuration procedure assumes that you have already configured your FTP server by following our How to setup FTP server on Ubuntu 18.04 LTS guide. Privileged access to your Ubuntu System as root or via sudo command is also required.
Configure SSH Daemon
If you have not done so yet, install SSH server:
$ sudo apt install ssh
Next, In order to configure FTP over OpenSSH server use your favorite text editor to edit existing SSHD configuration file /etc/ssh/sshd_config:
$ sudo nano /etc/ssh/sshd_config
and append the following to the end of the file:
Match group sftp
ChrootDirectory /home
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
The above lines will ensure that users belonging into sftp group will be able to access their home directories, however they will be denied SSH shell access.
Restart SSH server to apply new changes:
sudo service ssh restart
Create SFTP user account
We are almost done. All that remains is to create a new user account specific to SFTP service. Let’s start by creating a new group called sftp: