In my server (cpanel) I see now that with a simple DIR script (PHP) I can list files of all users over public_html
/home/[user]/public_html/
How can I prevent users from accessing the files of other users?
In my server (cpanel) I see now that with a simple DIR script (PHP) I can list files of all users over public_html
/home/[user]/public_html/
How can I prevent users from accessing the files of other users?
Your best bet, guessing that all users have different user id's, is to have their homes set to 0711
that is, readable, writable and executable to them, and only executable to others.
For a directory, the executable bit means that you can go in it but you can't list the content, which is what you're looking for.
When you create a user, create a group also with the same name
eg:
groupadd mike
useradd -g mike mike
and change group of all folders owned by user 'mike' to group 'mike'
chgrp -R mike /home/mike/
chmod 770
to all folders and chmod 640
to all files
and make all user's umask value to 0[2|7]7
in /etc/bashrc
, which will help to make these settings persistent for user accounts which will be created in future