0

I am trying to lock users into their home directory using a dedicated group in the sshd_config. The section of my group looks as follows

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

Using %h or even /home/%u wont work when I try to connect with any user. I checked all permissions on their home directories and everything looks ok.

Interestingly, when I provide ChrootDirectory with a static path, everything works fine.

E.g the following config lets users connect (but in the wrong directory)

Match Group sftponly
ChrootDirectory /home/
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

man sshd_config says that I am using the %h token correctly:

ChrootDirectory accepts the tokens %%, %h, %U, and %u.

Appreciate any hint since I spent hour on it already

1 Answer 1

1

As answered here here leading to here the ChrootDirectory has to be owned by root and can't be any group-write access.

As the home dirs of the specific user is by default owned by that user, your config is not working.

So either chown the home directory to root and create a folder in it where the user has the right to read/write or use a different ChrootDirectory.

1
  • thank you! I didnt stumble across those two pages while searching for a solution. It works fine now
    – azraelAT
    Jun 2, 2022 at 13:48

You must log in to answer this question.

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