Hello–
I’ve managed to get php (and all versions like php54, php71, etc) added to the jailshell with the following:
- Add the following to
/etc/jailkit/jk_init.ini
:
[php]
comment = php executables
executables = /usr/bin/php, /usr/bin/php74, /usr/bin/php54, /usr/bin/php55, /usr/bin/php56, /usr/bin/php70, /usr/bin/php71, /usr/bin/php72, /usr/bin/php73, /usr/bin/php74, /usr/bin/php80
includesections = env
[env]
comment = environment variables
executables = /usr/bin/env
- Remove the symlink for
bin
in the current chroot environment:
rm /chroot/bin
- Rebuild your jailshell with the following command:
jk_init -v -k -f -j /chroot/ uidbasics netbasics logbasics jk_lsh limitedshell ssh basicshell extendedshell terminfo editors php env
All the entries after /chroot/
correspond to headers in the /etc/jailkit/jk_init.ini
file. Please make sure you understand what they grant access to before allowing them. Just because I listed it above does not mean its inclusion is considered best security practice or the most secure set of options. The jailkit documentation is the best place to gain an understanding of all the options available to you in jailkit.
After that, php*
is available in a jailshell:
[primary@iw7 ~]$ php -v
PHP 7.3.27 (cli) (built: Feb 2 2021 10:32:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
[primary@iw7 ~]$ php55 -v
PHP 5.5.38 (cli) (built: Oct 22 2019 14:10:44)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
[primary@iw7 ~]$ php74 -v
PHP 7.4.16 (cli) (built: Mar 2 2021 10:35:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
@Nico, the other bash shell allows you access to php because it’s not locked to a chroot like chroot shell is. Once you enable chroot shell, if you go to /chroot
you’ll see bin
, etc
, usr
, etc. folders. The chroot is essentially a copy of only the commands/options you allow the user access to. The jk_init command copies these commands to the /chroot folder and then locks the user to only allow them to use the commands in that folder. In a jailshell, when you run php -v
you’re actually running /chroot/usr/bin/php
, in bash shell, you’re just running /usr/bin/php
. I hope that makes sense.
Brandon