Restricted sftp access to only /var/www

Posted February 17, 2017 1.7k views

How can I create an SFTP user with restricted access only for /var/www folder.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


How you’d go about this depends on what you’re comfortable managing. If you simply want users to use SFTP, the setup isn’t too complicated. If you want to physically put users in a chroot, it’s quite a bit more involved and more of a pain to manage / keep up with.

The most basic of ways would be to modify /etc/ssh/ssd_config and add a few setting to allow users to login with SFTP. This will prevent them from modifying other users files, and you can restrict their actual shell (i.e. prevent them from logging in to SSH), but it’s not as airtight as a well-setup chroot.

For example, if you want to go the chroot route, here’s a few links to guide you through the process.