I created the user MY_USER. Set his home dir to /var/www/RESTRICTED_DIR, which is the path he should be restricted to.
Then I edited sshd_config and set:
Match user MY_USER ChrootDirectory /var/www/RESTRICTED_DIR
Then I restarted ssh. Made MY_USER owner (and group owner) of RESTRICTED_DIR, and chmodded it to 755. I get
Accepted password for MY_USER session opened for user MY_USER by (uid=0) fatal: bad ownership or modes for chroot directory component "/var/www/RESTRICTED_DIR" pam_unix(sshd:session): session closed for user MY_USER
If I removed the 2 lines from sshd_config the user can login successfully. Of course it can access all the server though. What’s the problem? I even tried to chown RESTRICTED_DIR to root (as I read somewhere that someone solved this same problem doing it). No luck..