Q:

Changing ChrootDirectory to a sub directory within home directory

I'm creating users in my system, which are chroot jailed to their own home directory only using ‘/etc/ssh/sshd_config‘. It works fine, but I want to make it so ChrootDirectory will make their home directory to /home/%u/%u or /home/%u/public.
I have tried both, but it seems to always deny the connection when doing so and connecting using a FTP client as FlashFXP or FileZilla (/home/%u works).
Permissions are fine, as I am able to access the sub-directory when it's set to ‘ChrootDirectory /home/%u‘. What am I doing wrong then?

A:

man sshd_config:

ChrootDirectory
  Specifies the pathname of a directory to chroot(2) to after authentication.  At session startup sshd(8) checks that all components of the pathname are root-owned directories which are not writable by any other user or group.

You can use the home directory (but not a subdirectory) without tricks if you limit the users to SFTP:

In the special case when only sftp is used, not ssh nor scp, it is possible to use ChrootDirectory %h or ChrootDirectory /some/path/%u. The file system containing this directory must be mounted with options nodev and either nosuid or noexec. The owner of the directory should be the user. The ownership of the other components of the path must fulfill the usual conditions. No aditional files are required to be present in the directory.

Limitation to SFTP is possible with ForceCommand internal-sftp.

