Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've set up SFTP/SSH so that a user can only put to their home directory, however, they can still cd to all other directories and get files that they see.

How can I prevent this?


My sshd_config:

I've managed to lock to /var/www, but they can still view other user's folders.


Errm..... I just realized what I did wrong ... Ha ha

On another note, how could I make the public_html folder the folder that Apache tries to load data from?

share|improve this question

migrated from Dec 28 '12 at 13:26

This question came from our site for professional and enthusiast programmers.

You should configure sftp chroot.

share|improve this answer
That's what I've been trying to do for awhile now. Check the OP, just updated with link to my config. – David Harris Dec 28 '12 at 12:43
Here's a link to show how this "chroot" thing – Mats Petersson Dec 28 '12 at 13:03

Or you can do it with tools like

share|improve this answer


I did the following (I probably shouldn't have, but it worked for me. That's all I want):

Match user myUser
    ChrootDirectory /var/www/myUser
    ForceCommand internal-sftp
    AllowTcpForwarding no
    GatewayPorts no
    X11Forwarding no

In /var/www/myUser, I created the dir public_html. After that, I enabled the userdir apache mod, like this:

sudo a2enmod userdir
sudo service apache2 restart

And everything just... Works!

(of course, this has the obvious down-side that we now have to prepend usernames with a tilde)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.