#==============================================================================
#   UBUNTU 18.04 - SFTP ACCES WITHOUT ROOT OR SSH
#   https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-18-04
#==============================================================================
echo Username?
read user
echo domein voor toegang?
read domain
adduser $user
chown root:root /var/www
chmod 755 /var/www
chown $user:$user /var/www/$domain
cat <<EOF > /etc/ssh/sshd_config
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server

PermitRootLogin yes
Match User $user
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /var/www
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
EOF
systemctl restart sshd