How do I set permissions for my SFTP user?
Do you have any suggestions on how to handle permissions with a SFTP client? We have to keep changing permissions so we can actually make changes to the files. For example we need to run
chown -R sftp_user:sftp_user public_html/
And then afterwards run
chown -R apache:apache public_html/
Is there a way we can set it up so both the sftp_user and apache can access public_html
2 Replies
In this case, you actually have two options for how to handle this. The first would be to create a new group called, say “apachework” and assign the permissions to that group rather than the group for individual users. So in this case you would be able to run
usermod -a -G apachework sftp_user
then usermod -a -G apachework apache
That way both your users have the “apachework” group added. You can then modify the permissions for public_html/ so the owners group has read and write permissions. This would look something like:
chmod 661 public_html
this give the owner and group read and write permissions with world execute permission. (I have included world execute in case other applications such as PHP or MySQL need to run in the public_html folder but if this isn’t desired you can just get rid of the last 1 and substitute a 0)
The other option, if your distro supports it, is to take a look at using something like an Access Control List.
If you have other tips and tricks for managing users, groups and permissions on your Linode why not include them below? One of the great things about Linux is there are typically many different ways of accomplishing each task.
Worked great… We had to do chown -R :apachework public_html to get it to work.