Hello @Thaya
I want to restrict azure ADLS SFTP access to directory level
According to this MS-Document, the ACLs for local users are supported, but also still in preview. Please do not use this for your production environment.
- I had created ADLS gen2 storage account with name
venkat8912
. - A container (test) with two directories. (testdirectory1 and testdirectory2) with some files in both of them.
Portal:
The directory-level access restrictions are as follows:
-
testuser1
is permitted to list files only withintestdirectory1
and cannot perform any other operations in that directory. Additionally, testuser1 has no access to the root directory ortestdirectory2
. -
testuser2
is allowed to list files exclusively intestdirectory2
and is restricted from performing any other actions within that directory. testuser2 also has no access to the root directory ortestdirectory1
.
In addition to testuser1 and testuser2, an admin user is required to manage permissions. The admin user will have the authority to assign Access Control Lists (ACLs) for testuser1 and testuser2.
Admin:
While creating testuser1 and testuser2, leave containers and permissions empty, enable “Allow ACL authorization”, and set the landing directory to their respective directories (testdirectory1 or testdirectory2). This ensures access is controlled via ACLs and users are directed to their assigned directories.
testuser1:
testuser2:
After adding local user, you will get the userId
like below.
According to this MS-Document the ACLs contains three different permissions: Read[r], Write[w] and Execute[x]
Now connect with admin using PowerShell with sftp client.
Command:
PS > sftp ******@venkat8912.blob.core.windows.net
******@venkat8912.blob.core.windows.net's password:
Connected to venkat8912.blob.core.windows.net.
sftp>
The next step is to change the directory ownership: set testdirectory1’s owner to testuser1 and testdirectory2’s owner to testuser2. This ensures each user only has control over their assigned directory and cannot access the other.
sftp> chmod 1011 /
Changing mode on /
sftp> chown 1012 testdirectory1
Changing owner on /testdirectory1
sftp> chown 1013 testdirectory2
Changing owner on /testdirectory2
When connecting to the Storage Account via SFTP using testuser1 or testuser2, each user will only be able to list files within their respective directories (testdirectory1 or testdirectory2) and will be restricted from performing any other operations.
Output:
PS > sftp ******@venkat8912.blob.core.windows.net
******@venkat8912.blob.core.windows.net's password:
Connected to venkat8912.blob.core.windows.net.
sftp> ls
bloxxxor.docx bxxxor.docx coxxg.docx downloadxxmefile.docx
reaxxxfile.docx
sftp>
You can follow this same procedure to testuser2.
Reference:
How to configure directory level permission for SFTP local user | Microsoft Community Hub
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or are still running into more issues, let me know in the “comments” and I would be happy to help you.