I just tried the following to add a new user, chroot the user and give him access to the folder /home/me/public_html via sftp and ssh :
##the following command are done by root or a sudo user
useradd <username>
##add password for new user
passwd <username>
## add user to sudo group which could be wheel or sudo depending on your setup
usermod -G wheel <username>
##add user to apache as the public html folder is part of that group
usermod -G apache <username>
##Edit sshd_config to chroot the user. Path here below is on Centos or Redhat and with nano editor up and running
nano /etc/ssh/sshd_config
##add the end of the file add
Match User <username>
ChrootDirectory /path/of/choice
ForceCommand internal-sftp
## control X and save
service sshd restart
in sshd_config I have now
Match User <username>
ChrootDirectory /home/me/public_html
ForceCommand internal-sftp has been removed as line as there is no need to not allow SSH access based upon common made here below.
When I try to log in now I see
ssh <username>@domain.com
debug1: Next authentication method: password
<username>@domain.com's password:
debug1: Authentication succeeded (password).
Authenticated to domain.com ([xx.xxx.xx.xxx]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
Write failed: Broken pipe
Using SFTP in the log I see
Trace: Sent password
Trace: Access granted
Trace: Connection reset by peer
Error: Connection reset by peer
Error: Could not connect to server