From 7a0e1efc3fbb50089a50ac962932b60cc8594eb1 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 16 Nov 2026 17:29:02 +0100 Subject: [PATCH] Use 'sftpusers' as default SFTP chroot group, drop 'sftp-chroot' - create_vhost.sh: SFTP_CHROOT_GROUP defaults to 'sftpusers'. Fallback to 'sftpusers' only if a different, non-existing group is configured. Messages list only the groups actually tried. - create_vhost.conf.sample: example sshd Match block and default now use 'sftpusers'. Co-Authored-By: Claude Opus 5.5 --- conf/create_vhost.conf.sample | 8 ++++---- create_vhost.sh | 17 +++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/conf/create_vhost.conf.sample b/conf/create_vhost.conf.sample index d2a291d..d7c2e71 100644 --- a/conf/create_vhost.conf.sample +++ b/conf/create_vhost.conf.sample @@ -77,13 +77,13 @@ # - and "static site with suEXEC (chrooted SFTP access)"). # - # - The suEXEC user is added to this group, if it exists. Otherwise it is -# - added to group 'sftpusers' (if exists). If neither group exists, the +# - added to group 'sftpusers' (if exists). If no such group exists, the # - user is not added to any SFTP group. (The group is not created.) # - # - sshd must restrict members of this group, i.e. at the end of # - /etc/ssh/sshd_config: # - -# - Match Group sftp-chroot +# - Match Group sftpusers # - ChrootDirectory %h # - ForceCommand internal-sftp -u 0027 # - AllowTcpForwarding no @@ -92,6 +92,6 @@ # - PermitTunnel no # - PermitTTY no # - -# - Defaults to 'sftp-chroot' +# - Defaults to 'sftpusers' # - -#SFTP_CHROOT_GROUP="" +#SFTP_CHROOT_GROUP="sftpusers" diff --git a/create_vhost.sh b/create_vhost.sh index b9bffad..b8b4d22 100755 --- a/create_vhost.sh +++ b/create_vhost.sh @@ -313,10 +313,11 @@ CREATE_SYMLINK_WEB_BASE_DIR=false # - with chrooted SFTP access: # - sshd has to restrict members of that group to (chrooted) sftp # - -# - If this group does not exist, group 'sftpusers' is used (if exists). -# - If neither exists, the suEXEC user is not added to any SFTP group. +# - If a different group is configured (create_vhost.conf) and that group +# - does not exist, group 'sftpusers' is used (if exists). If no such group +# - exists, the suEXEC user is not added to any SFTP group. # - -SFTP_CHROOT_GROUP="sftp-chroot" +SFTP_CHROOT_GROUP="sftpusers" SFTP_CHROOT_GROUP_FALLBACK="sftpusers" @@ -591,6 +592,10 @@ fi # - ('sftpusers'), if it exists. If neither exists, no SFTP group is used. # - _sftp_group="" +_sftp_groups_tried="\"$SFTP_CHROOT_GROUP\"" +if [[ "$SFTP_CHROOT_GROUP_FALLBACK" != "$SFTP_CHROOT_GROUP" ]]; then + _sftp_groups_tried="${_sftp_groups_tried} / \"$SFTP_CHROOT_GROUP_FALLBACK\"" +fi if $_sftp_chroot ; then if [[ -n "$SFTP_CHROOT_GROUP" ]] && getent group "$SFTP_CHROOT_GROUP" > /dev/null ; then _sftp_group="$SFTP_CHROOT_GROUP" @@ -2107,7 +2112,7 @@ if $_print_summary ; then if [[ -n "$_sftp_group" ]]; then echo " SFTP chroot group (sshd).......: $_sftp_group" else - echo -e " SFTP chroot group (sshd).......: \033[33mnone\033[m (neither \"$SFTP_CHROOT_GROUP\" nor \"$SFTP_CHROOT_GROUP_FALLBACK\" exists)" + echo -e " SFTP chroot group (sshd).......: \033[33mnone\033[m (group not found: ${_sftp_groups_tried})" fi fi @@ -2491,9 +2496,9 @@ if $_suEXEC ; then fi fi else - echononl "\tAdd user \"$suEXEC_user\" to a SFTP group (\"$SFTP_CHROOT_GROUP\" / \"$SFTP_CHROOT_GROUP_FALLBACK\").." + echononl "\tAdd user \"$suEXEC_user\" to a SFTP group (${_sftp_groups_tried}).." echo_skipped - warn "Neither group \"$SFTP_CHROOT_GROUP\" nor group \"$SFTP_CHROOT_GROUP_FALLBACK\" exists.\n\t User \"$suEXEC_user\" was NOT added to a SFTP group." + warn "SFTP group not found: ${_sftp_groups_tried}.\n\t User \"$suEXEC_user\" was NOT added to a SFTP group." fi # - Webserver user must be able to read all files of the SFTP user