Restricted sftp access to only /var/www

February 17, 2017 425 views
DigitalOcean Ubuntu

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

Thanks

1 Answer

@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

Have another answer? Share your knowledge.