forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-sys-ssh-jail
More file actions
executable file
·69 lines (54 loc) · 2.1 KB
/
v-add-sys-ssh-jail
File metadata and controls
executable file
·69 lines (54 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# info: add system ssh jail
# options: NONE
#
# example: v-add-sys-ssh-jail
#
# This function enables ssh jailed environment.
#----------------------------------------------------------#
# Variables & Functions #
#----------------------------------------------------------#
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking if bubblewrap is installed
if [ ! -x /bin/bwrap ]; then
exit
fi
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Move jailbash to /usr/sbin
if [ ! -x /usr/sbin/jailbash ]; then
cp -f $HESTIA_COMMON_DIR/bubblewrap/jailbash /usr/sbin/jailbash
chmod +x /usr/sbin/jailbash
# only install the apparmor profile is abi 4.0 is available
if [ -f /etc/apparmor.d/abi/4.0 ]; then
cp -f $HESTIA_COMMON_DIR/bubblewrap/bwrap-userns-restrict /etc/apparmor.d/bwrap-userns-restrict
fi
service apparmor reload > /dev/null 2>&1
fi
# Register /usr/sbin/jailbash
if [ -z "$(grep ^/usr/sbin/jailbash /etc/shells)" ]; then
echo "/usr/sbin/jailbash" >> /etc/shells
fi
# Use sftp-server binary so the sftp process can run inside jailbash
if [ -z "$(grep 'Subsystem sftp /usr/lib/sftp-server' /etc/ssh/sshd_config)" ]; then
sed -i -E "s/Subsystem sftp internal-sftp/Subsystem sftp \/usr\/lib\/sftp-server/g" /etc/ssh/sshd_config
service ssh restart > /dev/null 2>&1
fi
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit