Assuming username is blog
and target folder is /home/blog
Make sure user blog
is exists and necessary permissions for the target folder is already set.
sudo nano /etc/ssh/sshd_config.d/blog.conf
Match User blog ForceCommand internal-sftp PasswordAuthentication yes ChrootDirectory /home/blog PermitTunnel no AllowAgentForwarding no AllowTcpForwarding no X11Forwarding no
sudo systemctl restart sshd
Now user may connect using sftp with the login credentials.
Let's say there is a folder called wordpress
in user's home directory and this directory is owned by www-data
user and group.
sudo usermod -a -G www-data blog
chmod g+rwxs /home/blog/wordpress
This will add
blog
user towww-data
group and give group access to files and directories in this folder even if they are; let's say 755 only user writable, now they are and any future files created in are group writable.
More detail from an askubuntu user: https://askubuntu.com/a/244410/1153321