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 <noreply@anthropic.com>
This commit is contained in:
1 parent
95034598b0
commit
d650fb499a
1 file changed
+15
-1
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user