1

When I setup chroot directory for SSH user, I set root as owner of this directory and set permissions to 755.

  1. Why must these directories be owned by root and have 755 permissions?

  2. Why can't the chrooted user be its owner?

  3. Why is the user able to read and write in it, while he doesn’t have such permission?

0

I'm assuming you refer to the ChrootDirectory option of OpenSSH.

  1. Why must these directories be owned by root and have 755 permissions?

  2. Why can't the chrooted user be its owner?

Given that chroots are usually used to limit what some process can do by limiting the set of available files, this is useful to prevent any accidents where some unauthorized user gets to modify the chroot environment.

The chrooted user itself could also do that, especially if they happen to have another way into the system. Also, it's probably simpler to just deny all non-root access rather than make an exception for the user in question.

  1. Why is the user able to read and write in it, while he doesn’t have such permission?

Well, they won't. But note that the ssh daemon changes to the user's home directory within the chroot, and they might well have read and write access there.

That is, you could have /path/to/chroot/home/user, where the user only has write access to that last directory.

| improve this answer | |

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.