@@ -18,17 +18,10 @@ source $HESTIA/func/main.sh
1818# load config file
1919source_conf " $HESTIA /conf/hestia.conf"
2020
21- restart=$1
22-
2321# ----------------------------------------------------------#
2422# Verifications #
2523# ----------------------------------------------------------#
2624
27- # Checking if jailkit is installed
28- if [ ! -x /sbin/jk_init ]; then
29- exit
30- fi
31-
3225# Checking if bubblewrap is installed
3326if [ ! -x /bin/bwrap ]; then
3427 exit
@@ -55,71 +48,6 @@ if [ -z "$(grep ^/usr/sbin/jailbash /etc/shells)" ]; then
5548 echo " /usr/sbin/jailbash" >> /etc/shells
5649fi
5750
58- # Checking sshd directives
59- config=' /etc/ssh/sshd_config'
60- ssh_i=$( grep -n " ^# Hestia SSH Chroot" $config )
61-
62- # Enabling jailed ssh
63- if [ -z " $ssh_i " ]; then
64- echo " " >> $config
65- echo " # Hestia SSH Chroot" >> $config
66- echo " Match Group ssh-jailed" >> $config
67- echo " ChrootDirectory /srv/jail/%u" >> $config
68- echo " X11Forwarding no" >> $config
69- echo " AllowTCPForwarding no" >> $config
70- restart=' yes'
71- fi
72-
73- # Validating opensshd config
74- if [ " $restart " = ' yes' ]; then
75- subj=" OpenSSH restart failed"
76- email=$( grep CONTACT " $HESTIA /data/users/$ROOT_USER /user.conf" | cut -f 2 -d \' )
77- /usr/sbin/sshd -t > /dev/null 2>&1
78- if [ " $? " -ne 0 ]; then
79- mail_text=" OpenSSH can not be restarted. Please check config:
80- \n\n$( /usr/sbin/sshd -t) "
81- echo -e " $mail_text " | $SENDMAIL -s " $subj " $email
82- else
83- service sshd restart > /dev/null 2>&1
84- fi
85- fi
86-
87- # Adding group
88- groupadd ssh-jailed 2> /dev/null
89-
90- # Checking jailkit init
91- jk_init=' /etc/jailkit/jk_init.ini'
92- jk_php_i=$( grep -n " ^# Hestia Jail Settings" $jk_init )
93-
94- # Add PHP to jailkit init to allow usage of it within jail
95- if [ -z " $jk_php_i " ]; then
96- cp -f $HESTIA_COMMON_DIR /jailkit/jk_init.ini /etc/jailkit
97- fi
98-
99- # Restart ssh service
100- if [ " $restart " = ' no' ]; then
101- # Skip restart of SSH daemon
102- echo " " > /dev/null 2>&1
103- else
104- service ssh restart > /dev/null 2>&1
105- fi
106-
107- # Jails need maintenance to update the binaries within the jail. To do so we just reset the chroot
108- # and reapply the jail
109- for user in $( " $BIN /v-list-users" list) ; do
110- check_jail_enabled=$( grep " SHELL_JAIL_ENABLED='yes'" $HESTIA /data/users/$user /user.conf)
111-
112- # If jail enabled try to jail the user
113- if [ -n " $check_jail_enabled " ]; then
114- $BIN /v-add-user-ssh-jail " $user " " no"
115- fi
116- done
117-
118- # Add v-add-sys-ssh-jail to startup
119- if [ ! -e " /etc/cron.d/hestia-ssh-jail" ]; then
120- echo " @reboot root sleep 60 && /usr/local/hestia/bin/v-add-sys-ssh-jail > /dev/null" > /etc/cron.d/hestia-ssh-jail
121- fi
122-
12351# ----------------------------------------------------------#
12452# Hestia #
12553# ----------------------------------------------------------#
0 commit comments