I have user that have a symlink to somewhere in the computer like this :

# ls -ltr /home/guirec0
total 4
lrwxrwxrwx 1 root    root      24 Jan  9 17:56 int -> /disk2/clients/optik/int
drwxr-xr-x 2 guirec0 guirec0 4096 Jan  9 18:13 blabla

I use sftp to connect to this user. I have this setup in /etc/ssh/sshd_config :

Subsystem sftp internal-sftp

Match Group sftpgroup
        ChrootDirectory %h
        ForceCommand internal-sftp
        X11Forwarding no
        AllowTcpForwarding no

So the root is changed and /disk2/clients/optik/int is not the same for root and for guirec0.

Is there a way to allow access /disk2/clients/optik/int for guirec0?

The goal of chrooting is to restrict access of the users.

  • Can you add another user, with the same uid, whose home directory is /disk2/clients/optik/int ? Jan 9, 2017 at 21:53

2 Answers 2


Use bind mount instead of symlink:

rm /home/guirec0/int
mkdir /home/guirec0/int
mount --bind /disk2/clients/optik/int /home/guirec0/int
  • I understand what you mean. So, I will have to write in /etc/fstab to make it persisting. I'm not very confortable with this. Is there a better way ?
    – Dougui
    Jan 9, 2017 at 19:28
  • @Dougui Move /disk2/clients/optik/int into /home/guirec0/int and symlink the other way round? Other than that, or remove the chroot from ssh config, no, bind-mount is the solution.
    – xhienne
    Jan 9, 2017 at 19:31
  • @xhienne I will use the mount solution but I have to find a way to add and remove from fstab safely
    – Dougui
    Jan 9, 2017 at 20:07
  • @Dougui You can add an entry to fstab with the "noauto" flag, so that it is not mounted automatically at boot.
    – xhienne
    Jan 9, 2017 at 20:23
  • @xhienne I don't want to change fstab manually or with a custom script because I don't want to do something wrong and not be able to reboot my os. Is there a command line tool to manipulate persisting mount points ?
    – Dougui
    Jan 9, 2017 at 20:26

If your source and destination are on the same filesystem, you can use a hard link:

ln /home/guirec0/int /disk2/clients/optik/int

This will survive a reboot.

But if /disk2/clients/optik/int is ever removed then re-created, the hardlink will refer to the old version.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .