Server Fault is a question and answer site for system and network administrators. 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'm pretty new to debian, and I'm trying to set up a server.

I have created a user who can only access his folder /home/username (and its subdirectory).

Now I want to use that user for the webserver I set up, and I have given him access to /var/www but I can't see /var/www through sftp and I did a symbolic link like this:

root@server:/home/username# ln -s /var/www www
root@server:/home/username# cd www
root@server:/home/username/www# chown username:username *

Now, with filezilla, I can see www folder like this:


But when I try to open it, I get this:


What I'm doing wrong?

share|improve this question
up vote 11 down vote accepted

It's likely the SFTP is being chrooted, so that the directory /var/www is not available to the user in the chroot jail.

Look in /etc/ssh/sshd_config and examine the sftp directives. Do you see something like:

Match group sftp
  ChrootDirectory /home/%u
  AllowTcpForwarding no
  ForceCommand internal-sftp

The sshd_config man page is here.

Basically, once the user is in /home/username in SFTP, that directory becomes / and references outside of /home/username are not available. In fact, a symlink like ln -s /var/www /home/username/www will look like you're trying to reach /home/username/var/www (i.e., /home/username is now / so any link that references /var/www must also be a subdirectory of /home/username in the context of the chroot).

As a solution, you can turn off the chroot (but this will have other security implications, mainly with SFTP users having full rein over your filesystem). You can do a loop mount of /var/www into /home/username/www (something like mount --bind /var/www /home/username/www (check your documentation for mount) which should work as you'd expect under chroot). You can also muck with the sshd_config file to exclude that one particular user from chroot (though, again, with security implications).

I would try the bind mount first.

share|improve this answer
+1 for the mount --bind trick! – Helge Klein Jul 31 '14 at 14:11
If you want it to be persistent across reboots, edit your /etc/fstab with a line like /home/username/www /var/www none bind 0 0 – pzkpfw Dec 23 '14 at 14:48

I resolved unlinking the symlink I made and with

root@server:/home/username# mkdir www
root@server:/home/username# mount --bind /home/username/www /var/www

(even if I've lost everything was in /var/www, but I don't care)

thanks all!

share|improve this answer
You haven't lost anything. Simply unmount and copy your files before you remount. – Zoredache Nov 14 '12 at 16:40
uuuhhh thank you! i had nothing but 1 file with a link, nothing important, but i couldn't figure out to recover it :D – Doc Nov 14 '12 at 16:41

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.