Restricted sftp access to only /var/www

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



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.


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.