Permission issues for new sftp users

#1
We have an issue with new sFTP users that we create - first of all following documentation on how to create new users is not working, so what we did is the following:
"sudo useradd -m {$name} -g www-data",
"echo '{$name}:{$password}' | sudo chpasswd",
"sudo mkdir -p {$ftpPath}",
"sudo chown root:root /home/{$url}",
"sudo chmod 755 /home/{$url}",
"sudo mount --bind {$originalWebsitePath} {$ftpPath}",
"sudo sh -c \"echo '{$originalWebsitePath} {$ftpPath} none bind 0 0' >> /etc/fstab\"",

// Update the permissions and ownership
"sudo chown -R {$name}:www-data {$originalWebsitePath}",
"sudo find {$originalWebsitePath} -type d -exec chmod 775 {} +",
"sudo find {$originalWebsitePath} -type f -exec chmod 775 {} +",
"grep -qxF 'Match User {$name}' /etc/ssh/sshd_config || echo 'Match User {$name}\nChrootDirectory /home/{$url}\nForceCommand internal-sftp\nPasswordAuthentication yes\nPermitRootLogin no\nAllowTcpForwarding no' >> /etc/ssh/sshd_config",
"sudo service ssh restart",
"systemctl restart lsws",

And this works, but the issue is that all the files that this new user creates have permission of 664, which means that WordPress cant edit files created by this user. Any idea how to fix that?
 

Cold-Egg

Administrator
#2
If the sftp user and WordPress are in the same group, then WordPress should have permission to edit it when the file permission is set to 664, although 644 is the default one.
 
Top