Currently I use the following configuration
mkdir -p /var/www
chmod -R 555 /var/www
mkdir -p /var/www/user1
chown root:root /var/www/user1
useradd user1
usermod user1 -s /bin/false
usermod user1 -d /var/www/user1
mkdir -p /var/www/user1/html/com.domain.site1
chmod 750 /var/www/user1/html/com.domain.site1
chown -R user1:www-data /var/www/user1/html
chmod -R g+s /var/www/user1/html
groupadd allowSFTP
usermod -a -G allowSFTP user1
For SFTP Access I add this to sshd_conf
Subsystem sftp internal-sftp
Match Group allowSFTP
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
Thus, each user has access only to his own directories via SFTP.
Now I still have SSH enabled for the user
Match Group allowSFTPandSSH
ChrootDirectory %h
AllowTcpForwarding no
X11Forwarding no
usermod user1 -s /bin/bash
How do I get the user to be trapped in his folder? With ChrootDirectory he can no longer log in because /bin/bash is no longer found.
If the user now uses e.g. npm or something else, there is an error, because the user has too few permissions in the folder "/var/www/user1/" folder or files like .npm, cache,... in the folder. I can create these as admin and then it works. But can I also change something so that the user has the permissions?