From d650fb499accdbd33bc622acd60203357a22b094 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 16 Nov 2026 13:44:52 +0100 Subject: [PATCH] set_suexec_users_nologin.sh: skip users with ssh keys, no error if no suexec users. - Users with a non-empty ~/.ssh/authorized_keys are skipped, they would lose their ssh/sftp access with shell '/usr/sbin/nologin'. - Finding no suexec users at all is reported as info (exit 0), not as fatal. Co-Authored-By: Claude Opus 5.5 --- set_suexec_users_nologin.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/set_suexec_users_nologin.sh b/set_suexec_users_nologin.sh index 8234a7a..6c510b2 100755 --- a/set_suexec_users_nologin.sh +++ b/set_suexec_users_nologin.sh @@ -254,7 +254,12 @@ done < <( | awk '{print $2}' | sort -u ) -[[ ${#suexec_user_arr[@]} -gt 0 ]] || fatal "No suexec users found in '${_vhost_base_dir}'." +# - No suexec users at all is not an error - just nothing to do +# - +if [[ ${#suexec_user_arr[@]} -eq 0 ]] ; then + info "No suexec users found in '${_vhost_base_dir}' - nothing to do." + clean_up 0 +fi echo "" @@ -320,6 +325,15 @@ for _user in "${suexec_user_arr[@]}" ; do continue fi + # - Don't touch users with ssh keys - they would lose their (ssh/sftp) access + # - + _home_dir="$(echo "$_passwd_entry" | cut -d: -f6)" + if [[ -s "${_home_dir}/.ssh/authorized_keys" ]] ; then + echo_skipped + echo -e " \033[33mUser has '${_home_dir}/.ssh/authorized_keys' (ssh access in use?)\033[m" + continue + fi + if $dry_run ; then echo_skipped echo -e " \033[33mDry-run:\033[m would change shell $_shell --> $new_shell"