@@ -51,29 +51,42 @@ if [ -d "/home/$user" ]; then
5151 chown root:root /home/$user
5252fi
5353
54- add_chroot_jail " $user "
55-
56- # Add user to the ssh-jailed group to allow jailed ssh
57- # This needs to be done first to make sure these groups are made available in the jail
58- usermod -a -G ssh-jailed $user
59-
60- # Installing shell files into the user chroot directory
61- # - IMPORTANT - MODIFY THE FOLLOWING LINES AND THE FILE jk_init.ini ACCORDING TO YOUR SYSTEM AND YOUR PREFERENCES
62- /sbin/jk_init -f -j $chroot extendedshell netutils ssh sftp scp git php php5_6 php7_0 php7_1 php7_2 php7_3 php7_4 php8_0 php8_1 php8_2 > /dev/null 2>&1
63- /sbin/jk_cp -f -j $chroot /bin/id > /dev/null 2>&1
64-
65- # Jailing user to make sure passwd and groups are set correctly within the jail.
66- # This command also does a little too much by changing the users homedir and
67- # shell in /etc/passwd. The next commands reverts those changes for compatibility
68- # with hestia.
69- /sbin/jk_jailuser -n -s $shell_path -j $chroot $user
70-
71- # Reset home directory and shell again for hestiacp because jailkit changes these.
72- # Normally these are needed to redirect the ssh user to it's chroot but because we
73- # use a custom sshd_config to redirect the user to it's chroot we don't need it to be
74- # changed in /etc/passwd for the user.
75- usermod -d /home/$user $user
76- usermod -s $shell_path $user
54+ # Prevent from enabling for users hen rssh or nologin is enabled
55+ user_str=$( grep " ^$user :" /etc/passwd | egrep " rssh|nologin" )
56+ if [ -n " $user_str " ]; then
57+ exit
58+ fi
59+
60+ if [ ! -d " $chroot " ]; then
61+ add_chroot_jail " $user "
62+
63+ # Add user to the ssh-jailed group to allow jailed ssh
64+ # This needs to be done first to make sure these groups are made available in the jail
65+ usermod -a -G ssh-jailed " $user "
66+
67+ # Installing shell files into the user chroot directory
68+ # - IMPORTANT - MODIFY THE FOLLOWING LINES AND THE FILE jk_init.ini ACCORDING TO YOUR SYSTEM AND YOUR PREFERENCES
69+ /sbin/jk_init -f -j " $chroot " extendedshell netutils ssh sftp scp git php php5_6 php7_0 php7_1 php7_2 php7_3 php7_4 php8_0 php8_1 php8_2 > /dev/null 2>&1
70+ /sbin/jk_cp -f -j " $chroot " /bin/id > /dev/null 2>&1
71+
72+ # Jailing user to make sure passwd and groups are set correctly within the jail.
73+ # This command also does a little too much by changing the users homedir and
74+ # shell in /etc/passwd. The next commands reverts those changes for compatibility
75+ # with hestia.
76+ /sbin/jk_jailuser -n -s " $shell_path " -j " $chroot " " $user "
77+
78+ # Reset home directory and shell again for hestiacp because jailkit changes these.
79+ # Normally these are needed to redirect the ssh user to it's chroot but because we
80+ # use a custom sshd_config to redirect the user to it's chroot we don't need it to be
81+ # changed in /etc/passwd for the user.
82+ usermod -d " /home/$user " " $user " > /dev/null 2>&1
83+ usermod -s " $shell_path " " $user " > /dev/null 2>&1
84+
85+ else
86+ /sbin/jk_update -f -j " $chroot " > /dev/null 2>&1
87+ usermod -d " /home/$user " " $user " > /dev/null 2>&1
88+ usermod -s " $shell_path " " $user " > /dev/null 2>&1
89+ fi
7790
7891# ----------------------------------------------------------#
7992# Hestia #
0 commit comments