I want to add a second SFTP user that can only view a couple of folders/files in a home folder. I already added a group
sftp_users for the normal users but now I am searching for a solution to add a read only user for the same folder.
One solution might be:
- Set a new group (e.g. sftp_users_ro)
- Give the new sftp user the new group
- set the following permissions to the folder: 775
The user and group which owner the folder will have read/write/execute permission in this folder.
The new sftp user will have read/execute permissions to the folder (without write permission)
See this Q&A for more info What is meaning of 755 permissions in Samba Share
You can use ACLs (Access control lists). You can grant read access to an user with:
setfacl -m u:lisa:r file
However, your sftp server needs to support, so check that out before trying. Also, there're some clients which don't support Linux ACLs (I might be wrong but I think WinSCP still doesn't support ACLs).