5

I created a user on my server specifically for an external application. I want the application to be able to ssh into the user account and cd into a directory. However, it keeps saying permission denied when I try to do that. I set the permissions on the folder to "Access," thinking this will do the trick.

Here is a screenshot of the folder permissions :

enter image description here

What gives?

  • 3
    What are the permissions of the parent folder? – Kaz Wolfe Dec 30 '16 at 21:19
6

Your parent folder must be readable (in a sense) too.

For example, I have a folder test, with another folder, test2 inside of it. Permissions are as such:

drwxrwx---   3 kazwolfe kazwolfe     4096 Dec 30 13:18 test/
drwxrwxr-x   2 kazwolfe nogroup      4096 Dec 30 13:18 test/test2

As you can see, the nobody user (member of nogroup) has permissions for test/test2, but it can't cd into it:

cd: test/test2: Permission denied

Why? Simply put, because the nobody user does not have rights to read from test. Therefore, they are blocked from accessing any subdirectories or subfiles of test, even if they have permission!

In order to resolve this, I need to ensure that the execute bit (chmod a+x test) on any parent folder is set so I can traverse the folder(s) needed:

┌─[13:35:22]─[nobody@ArcticWolf]
└──> ~ $ cd test
┌─[13:35:24]─[nobody@ArcticWolf]
└──> test $ ll
ls: cannot open directory '.': Permission denied
┌─[✗]─[13:35:27]─[nobody@ArcticWolf]
└──> test $ cd test2
┌─[13:35:31]─[nobody@ArcticWolf]
└──> test2 $ touch hello
┌─[13:35:34]─[nobody@ArcticWolf]
└──> test2 $ ll
total 8
drwxrwxr-x 2 kazwolfe nogroup  4096 Dec 30 13:35 ./
drwxrwx--x 3 kazwolfe kazwolfe 4096 Dec 30 13:22 ../
-rw-r--r-- 1 nobody   nogroup     0 Dec 30 13:35 hello

Note that setting the execute bit on a folder allows a user to access anything inside the folder that they have permission for, and know exists. See this answer on U&L for a more in-depth view of permissions on folders.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.