This configuration gives a user SFTP access to a single directory (chroot), and disables them from navigating outside of that directory or accessing SSH.
Create directory that you want the new user to access
Create the user and an SFTP group. Second command also sets the user’s home directory to the one we created earlier.
useradd -d /customers/newguy newguy
Add the new user to sftp group and disable their SSH access
usermod -g sftp newguy
usermod -s /bin/false newguy
Set the proper permissions on their directory
chown root:root /customers/newguy
chmod 750 /customers/newguy
Limit users in the sftp group to their home directories by pasting the code below in
Match group sftp
The user won’t be able to create anything in their home folder, so make them another directory and give them permissions to write in it.
chown -R newguy.newguy /customers/newguy/myfiles
chmod 750 /customers/newguy/myfiles