Report this

What is the reason for this report?

Restricted sftp access to only /var/www

Posted on February 17, 2017

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

Thanks



This textbox defaults to using Markdown to format your 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.

@serkanersan

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.

https://olivier.sessink.nl/jailkit/

http://allanfeid.com/content/creating-chroot-jail-ssh-access

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.