1

I created a user on Centos 7 via webmin and pointed /var/www/html/page as their home directory so when they log in they start from there.

However, I logged in myself and realized that they can navigate from there to the upper directories which I don't want. How can I prevent this from happening?

2

You can prevent users accessing directories and files outside their home location by using chroot, often referred to as chroot jail.

A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally cannot access) files outside the designated directory tree.

You will find many questions, answers, and guides on the Unix Stack and Google.

  • Thank you but Im not using vsftpd. What should I do? – Cain Nuke May 25 '17 at 16:01
  • chroot is Linux, not vsftp. Linked guide is one of hundreds that can be found online. – Simon Hayter May 25 '17 at 16:27
  • The guide addresses how to do it specifically for vsftpd by editing the configuration file but since I dont use that, which configuration file should I edit? – Cain Nuke May 25 '17 at 16:38
  • Since you haven't told us what you're using, its anyones guess. You first need to know what FTP server software your using, i.e SSH, ProFTPD, PureFTPD, WU-FTPD etc. Please note that this question is borderline off-topic because it's now becoming a more related to Linux administration. than administrating a website. You may get a better response from the community the Unix stack assuming that you ensure your question is specific, not unclear and satisfies the rest of their quality question guidelines. – Simon Hayter May 25 '17 at 17:47
  • This is often a slightly tricky balance. Instead, I often use a group created for the purpose and add the group to the directory tree at the top level directory you want to give access to. This is the reverse of adding a user to an existing group. For ftp, your are always accessing with file level privileges. This is what you need to learn and figure out. Creating a new group allows you to precisely control access. You can use this with user names too, however groups can serve more than one user and can be easier to manage. Cheers!! – closetnoc May 26 '17 at 1:47

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.