Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 need to setup some users to access our server. I thought the most secure way to allow them access was to setup a chroot'ed jail for them to log into.

But I need them to access a few select directories that are outside the chroot'ed environment. Apparently I can't use symlinks for this. What is the best approach? Can a chroot'ed environment not be used for this purpose?

share|improve this question
Isn't the whole point of a chroot'ed environment to prevent access to files outside of the chroot? So, any way around that would be a bug? – Andrew Barber Nov 15 '10 at 23:46
Maybe you could suggest a better way for me to set this up then? – Jake Wilson Nov 15 '10 at 23:51
up vote 9 down vote accepted

This is a place where a bind mount will do what you want.

share|improve this answer
A bind mount would likely be the best way out of this hole. "mount -o bind /dir/outside/chroot /dir/inside/chroot" To survive a reboot add "/dir/inside/chroot /dir/outside/chroot none bind 0 0" to your /etc/fstab file. – Rik Schneider Nov 16 '10 at 3:18
Brilliant. Thanks! – Jake Wilson Nov 17 '10 at 4:01

If it's on the same filesystem and it's individual files, hardlinks will work.

Softlinks will not work: the main purpose of a chroot'ed jail is that users can't get out to access files that aren't inside there.

You can use cp -lr to duplicate a directory tree with each file being a hardlink to the same underlying file, but that won't immediately pick up renames/moves, new files or deletes.

I think @SvenW has the best idea: move the directory into the chroot area and make the current location a symlink to the version inside the chroot.

share|improve this answer
I get "Invalid cross-device link". The files are on a different internal hdd. Guess that's not gonna work. – Jake Wilson Nov 15 '10 at 23:52
Maybe you could move the files into the required file system and then maybe use symlinks for other non-chrooted users? – Sven Nov 16 '10 at 0:53

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.