I have a server that multiple users access via sftp. They do not have ssh access and they are contained to their home directory by setting the ChrootDirectory /home/%u
in the /etc/ssh/sshd_config
file. I want one user to be able to access an entire directory containing files uploaded by another user. I tried creating a symlink: ln -s /home/user2/files /home/user1/other_files
but when user1 logs in, they can see the link but not navigate to it. If I ssh into the box, I can use the other_files symlink to see the uploaded files, but the sftp users cannot (they get a permisisons error when accessing).
Can I allow these users to share files automatically while still containing them to their home directory? I know the symlink points to a path outside of their directory, which I believe is causing the permission issue. I can't manually move the files - the uploads are automatic and occur frequently, so I need user1 to be able to see the files as soon as they're uploaded. If I recreate the users with the same home directory and adjust the permissions of their respective upload directorys, would that allow user 1 to get the files? Ideally, user 2 shouldn't have access to any of user 1's files, but if that has to happen, it will still work for me.
cp -al
to copy an entire directory tree as hard links.cp -al
works, but only for the files that currently exist. If user 2 uploads another file after the command has been run, it doesn't show in the copied folder for user 1. Is there no way to automatically update the folder as new items are uploaded?inotify
. You could use some technology based oninotify
(such as, perhaps,incron
) to monitor changes in specific directories and automate the creation/deletion of hard links between chrooted directories.