I would like to create a new user with read/write privileges ONLY in the /var/www/ directory including all sub-directories. The /var/www/ is owned by a group called www-data.Best way to do it I guess is with SFTP. I already have SSH access as root.I'm a complete newbie with linux but this theoretical easy task is driving me crazy. Many other answers relating to restricting SFTP access are related to the /home/ directory and require to change ownership of directory to root and I don't know if it's a good idea to do that also on the www directory.
Restrict user to do SFTP on the www folder owned by www-data group
linux;ubuntu;users;useradd;wordpress
You can create a user, set its home directory to /var/www/ and add him to the www-data group. If you want the files he will create belongs to the www-data group, you'll have to add the s bit to the www directory's mod.# useradd -m /var/www -g www-data# chmod g+s /var/wwwOr did I missunderstand the question? Maybe you want that this user can't read any other directory? In this case you can chroot him:http://how-to.linuxcareer.com/how-to-automatically-chroot-jail-selected-ssh-user-loginsIf you want to use SFTP: https://bensmann.no/restrict-sftp-users-to-home-folder/s bit: http://en.wikipedia.org/wiki/Chmod#Special_modeshttp://en.wikipedia.org/wiki/Setuid