As of right now I have a configuration section on my sshd config like so

Match Group purecore
  ChrootDirectory /etc/purecore/hosted/%u
  ForceCommand internal-sftp

Where %u is the username of the user logging in. In my users setup, I always create users with the usernames beginning with 'u' (in order to prevent usernames to start with a number). Since all the users start with 'u', I would love the user 'uxxx' to have its chroot directory to /etc/purecore/hosted/xxx, instead of /etc/purecore/hosted/uxxx. Is there any possible way to create a substring of %u in the sshd_config itself, removing the first character? Or taking last x characters?

Note this is purely for aesthetic purposes in my filesystem. Thank you!


If /etc/purecore/hosted/xxx is the home directory for user, you can use %h, which points to the home directory of the user. More information here: https://man.openbsd.org/sshd_config#TOKENS

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.