SFTP: file symlinks in a jailed (chrooted) directory

Solution 1:

Symlinks are purely symbolic: they contain nothing but a path, so when you open a symlink, the OS reads the path and uses that instead. In a chroot environment, links (especially ones with absolute paths) typically don't point to the same place they pointed to in the normal environment.

If the server OS is Linux, your best bet is to bind-mount the entire directory somewhere inside the chroot directory. When using this, its important to remember that this is not a copy of the directory, anything deleted here will be removed from the other directory (important if the user can mv files or rm -rf). To do this:

mount --bind /some/directory /somewhere/else

The files in the directory ought to be real files. Symlinks here will probably have the same problems you have trying to link to the files in the first place.