Skip to content

Commit 5482117

Browse files
committed
When jail exists just run update
1 parent 056a167 commit 5482117

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

bin/v-add-user-ssh-jail

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,36 @@ if [ -n "$user_str" ]; then
5757
exit
5858
fi
5959

60+
if [ ! -d "$chroot" ]; then
6061
add_chroot_jail "$user"
6162

6263
# Add user to the ssh-jailed group to allow jailed ssh
6364
# This needs to be done first to make sure these groups are made available in the jail
64-
usermod -a -G ssh-jailed $user
65+
usermod -a -G ssh-jailed "$user"
6566

6667
# Installing shell files into the user chroot directory
6768
# - IMPORTANT - MODIFY THE FOLLOWING LINES AND THE FILE jk_init.ini ACCORDING TO YOUR SYSTEM AND YOUR PREFERENCES
68-
/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
69-
/sbin/jk_cp -f -j $chroot /bin/id > /dev/null 2>&1
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
7071

7172
# Jailing user to make sure passwd and groups are set correctly within the jail.
7273
# This command also does a little too much by changing the users homedir and
7374
# shell in /etc/passwd. The next commands reverts those changes for compatibility
7475
# with hestia.
75-
/sbin/jk_jailuser -n -s $shell_path -j $chroot $user
76+
/sbin/jk_jailuser -n -s "$shell_path" -j "$chroot" "$user"
7677

7778
# Reset home directory and shell again for hestiacp because jailkit changes these.
7879
# Normally these are needed to redirect the ssh user to it's chroot but because we
7980
# use a custom sshd_config to redirect the user to it's chroot we don't need it to be
8081
# changed in /etc/passwd for the user.
81-
usermod -d /home/$user $user
82-
usermod -s $shell_path $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
8390

8491
#----------------------------------------------------------#
8592
# Hestia #

bin/v-delete-user-ssh-jail

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ user_shell_rssh_nologin=$(grep "^$user:" /etc/passwd | egrep "rssh|nologin")
4545
if [ -z "$user_shell_rssh_nologin" ]; then
4646
# chown permissions back to user:user
4747
if [ -d "/home/$user" ]; then
48-
chown $user:$user /home/$user
48+
chown "$user":"$user" "/home/$user"
4949
fi
5050

5151
# Deleting chroot jail for SSH
52-
delete_chroot_jail $user
52+
delete_chroot_jail "$user"
5353
fi
5454

5555
# Deleting user from groups
56-
gpasswd -d $user ssh-jailed > /dev/null 2>&1
56+
gpasswd -d "$user" ssh-jailed > /dev/null 2>&1
5757

5858
#----------------------------------------------------------#
5959
# Hestia #

0 commit comments

Comments
 (0)