Question

how can I make folder accessible by one user

I’ve followed this tutorial to make apache virtual hosts.

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

What I want is to restrict user access to the domain path [ /var/www/domain.com/public_html ].

e.g: user “none” can only operate on this folder { /var/www/devmuath.com/public_html }

  • he can use SSH - and sftp programs like filezilla

I’m still new on Ubuntu, so please give step by step instructions.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Sorry for being late!

I tried to log in to the server from the user who has the problem and here is the log.

Oct 16 18:42:17 ibrahimh sshd[9947]: Accepted password for root from 2X.X9.18.X0 port 16041 ssh2
Oct 16 18:42:17 ibrahimh sshd[9947]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 16 18:42:17 ibrahimh systemd-logind[789]: New session 882 of user root.


Oct 16 18:45:57 ibrahimh sshd[10048]: Accepted password for mouath from 2X.X9.18.X0 port 16394 ssh2
Oct 16 18:45:57 ibrahimh sshd[10048]: pam_unix(sshd:session): session opened for user mouath by (uid=0)
Oct 16 18:45:57 ibrahimh systemd: pam_unix(systemd-user:session): session opened for user mouath by (uid=0)
Oct 16 18:45:57 ibrahimh systemd-logind[789]: New session 883 of user mouath.
Oct 16 18:45:58 ibrahimh sshd[10142]: fatal: bad ownership or modes for chroot directory component "/var/www/"
Oct 16 18:45:58 ibrahimh sshd[10048]: pam_unix(sshd:session): session closed for user mouath
Oct 16 18:45:58 ibrahimh systemd-logind[789]: Removed session 883.

What’s in the error log? Run this right after you attempt a restart of sshd:

journaltctl -xe

This is a good tutorial on how to do that: https://www.tecmint.com/restrict-sftp-user-home-directories-using-chroot/

Make sure to disable SSH login just like the tutorial shows. Otherwise it’s easy to circumvent the restrictions.