[Solved] Jailkit: 1st terminal config problem, now ssh login problem

Discussion in 'Installation/Configuration' started by Nap, Feb 8, 2016.

  1. Nap

    Nap Member

    Initially I had a problem on a particular user where the terminal (in PuTTY) wasn't displaying colours correctly and nor responding to home/end keys.
    I was advised that I probably had some missing files in my jail (like /etc/inputrc) and needed them. Sure enough /etc/inputrc was not there.

    So I searched here about configuring JailKit and read the olivier.sessink site. First I tried jk_init -v -f -k -j /var/www/clients/client1/web2 extendedshell but that didn't solve the problem and actually showed some errors. On loggin in, I was still having the same issues with colour and keys. So I tried jk_update -j /var/www/clients/client1/web2 instead. This removed a bunch of outdated and deprecated files ... but the problem wasn't fixed.

    Now I can't login using SSH, and jk_init -v -f -k -j /var/www/clients/client1/web2 ssh did not fix this.
    I was logged in (ssh session and SFTP on WinSCP) on the jailed account during some of the steps below, which may have contributed to some of my issues.
    My bin folder only has ls and a symlink to sh.

    Any help would be greatly appreciated,
    Nap.


    Here is a log of my attempts to fix the original problem and the ssh problem (last command):
    My commands are in bold.
    /jail => /var/www/clients/client1/web2
    I prunned entries from common folders so that only one entry shows here, a blank line under it marks these.

    user@server:[18:14]:/etc/jailkit# jk_init -v -f -k -j /jail extendedshell
    Source file(s) /lib/libnsl.so.1 do not exist
    Source file(s) /lib64/libnsl.so.1 do not exist
    Source file(s) /lib/libnss*.so.2 do not exist
    Source file(s) /lib64/libnss*.so.2 do not exist
    Creating symlink /jail/lib/x86_64-linux-gnu/libnss_compat.so.2 to libnss_compat-2.19.so
    Destination file /jail/lib/x86_64-linux-gnu/libnss_compat-2.19.so exists, will delete to force update
    Trying to link /lib/x86_64-linux-gnu/libnss_compat-2.19.so to /jail/lib/x86_64-linux-gnu/libnss_compat-2.19.so
    Creating symlink /jail/lib/x86_64-linux-gnu/libnsl.so.1 to libnsl-2.19.so
    Destination file /jail/lib/x86_64-linux-gnu/libnsl-2.19.so exists, will delete to force update
    Trying to link /lib/x86_64-linux-gnu/libnsl-2.19.so to /jail/lib/x86_64-linux-gnu/libnsl-2.19.so
    Creating symlink /jail/lib/x86_64-linux-gnu/libc.so.6 to libc-2.19.so
    Destination file /jail/lib/x86_64-linux-gnu/libc-2.19.so exists, will delete to force update
    Trying to link /lib/x86_64-linux-gnu/libc-2.19.so to /jail/lib/x86_64-linux-gnu/libc-2.19.so
    Create directory /jail/lib64
    Traceback (most recent call last):
    File "/usr/sbin/jk_init", line 244, in <module>
    main()
    File "/usr/sbin/jk_init", line 241, in main
    activateConfig(config, jail, args)
    File "/usr/sbin/jk_init", line 161, in activateConfig
    ji.handle_cfg_section(config,jail,cfg,section)
    File "/usr/sbin/jk_init", line 98, in handle_cfg_section
    self.handle_cfg_section(config,chroot,cfg,tmp)
    File "/usr/sbin/jk_init", line 98, in handle_cfg_section
    self.handle_cfg_section(config,chroot,cfg,tmp)
    File "/usr/sbin/jk_init", line 107, in handle_cfg_section
    self.didfiles = jk_lib.copy_binaries_and_libs(chroot, paths2, config['force'], config['verbose'], 1, try_hardlink=config['hardlink'],try_glob_matching=1,handledfiles=self.didfiles)
    File "/usr/share/jailkit/jk_lib.py", line 633, in copy_binaries_and_libs
    handledfiles = copy_binaries_and_libs(chroot, ret, force_overwrite, be_verbose, check_libs, try_hardlink=try_hardlink, retain_owner=retain_owner, try_glob_matching=0, handledfiles=handledfiles)
    File "/usr/share/jailkit/jk_lib.py", line 695, in copy_binaries_and_libs
    handledfiles = copy_binaries_and_libs(chroot, [realfile], force_overwrite, be_verbose, check_libs, try_hardlink, allow_suid, retain_owner, handledfiles)
    File "/usr/share/jailkit/jk_lib.py", line 714, in copy_binaries_and_libs
    handledfiles = copy_binaries_and_libs(chroot, libs, force_overwrite, be_verbose, 0, try_hardlink, handledfiles=handledfiles)
    File "/usr/share/jailkit/jk_lib.py", line 642, in copy_binaries_and_libs
    create_parent_path(chroot,os.path.dirname(file), be_verbose, copy_permissions=1, allow_suid=allow_suid, copy_ownership=retain_owner)
    File "/usr/share/jailkit/jk_lib.py", line 464, in create_parent_path
    os.mkdir(jailpath, 0755)
    OSError: [Errno 13] Permission denied: '/jail/lib64'
    user@server:[18:14]:/etc/jailkit# jk_update -j /jail
    removing outdated file /jail/bin/ls

    removing outdated file /jail/lib/terminfo/r/rxvt

    removing deprecated file /jail/lib/libcap.so.2

    removing deprecated file /jail/lib/tls
    ERROR: failed to remove deprecated file /jail/lib/tls

    removing deprecated file /jail/lib/i686
    ERROR: failed to remove deprecated file /jail/lib/i686

    removing outdated file /jail/usr/lib/openssh/sftp-server
    removing outdated file /jail/usr/bin/cut

    removing outdated file /jail/usr/sbin/jk_lsh
    removing deprecated file /jail/usr/lib/liblwres.so.60.0.0

    ERROR: failed to remove deprecated file /jail/usr/lib/locale/en_US.utf8
    removing deprecated file /jail/usr/share/terminfo/m/mach-color

    ERROR: failed to remove deprecated file /jail/usr/share/vim/vim72
    removing deprecated file /jail/usr/share/vim/vimcurrent
    ERROR: while scannign dir /jail/opt/: No such file or directory
    Copying /bin/ls to /jail/bin/ls
    Copying /lib/x86_64-linux-gnu/libselinux.so.1 to /jail/lib/x86_64-linux-gnu/libselinux.so.1
    Creating symlink /jail/lib/x86_64-linux-gnu/libacl.so.1 to libacl.so.1.1.0
    Copying /lib/x86_64-linux-gnu/libacl.so.1.1.0 to /jail/lib/x86_64-linux-gnu/libacl.so.1.1.0
    Creating symlink /jail/lib/x86_64-linux-gnu/libpcre.so.3 to libpcre.so.3.13.1
    Copying /lib/x86_64-linux-gnu/libpcre.so.3.13.1 to /jail/lib/x86_64-linux-gnu/libpcre.so.3.13.1
    Creating symlink /jail/lib/x86_64-linux-gnu/libdl.so.2 to libdl-2.19.so
    Copying /lib/x86_64-linux-gnu/libdl-2.19.so to /jail/lib/x86_64-linux-gnu/libdl-2.19.so
    Traceback (most recent call last):
    File "/usr/sbin/jk_update", line 265, in <module>
    main()
    File "/usr/sbin/jk_update", line 262, in main
    updatejail(jail, dirs, skips, config)
    File "/usr/sbin/jk_update", line 166, in updatejail
    handled = jk_lib.copy_binaries_and_libs(jail,allfiles, 0, config['verbose'], try_hardlink=config['hardlink'])
    File "/usr/share/jailkit/jk_lib.py", line 714, in copy_binaries_and_libs
    handledfiles = copy_binaries_and_libs(chroot, libs, force_overwrite, be_verbose, 0, try_hardlink, handledfiles=handledfiles)
    File "/usr/share/jailkit/jk_lib.py", line 642, in copy_binaries_and_libs
    create_parent_path(chroot,os.path.dirname(file), be_verbose, copy_permissions=1, allow_suid=allow_suid, copy_ownership=retain_owner)
    File "/usr/share/jailkit/jk_lib.py", line 464, in create_parent_path
    os.mkdir(jailpath, 0755)
    OSError: [Errno 13] Permission denied: '/jail/lib64'
    user@server:[18:19]:/etc/jailkit# jk_update -j /jail
    removing deprecated file /jail/lib/tls
    ERROR: failed to remove deprecated file /jail/lib/tls
    removing deprecated file /jail/lib/i686
    ERROR: failed to remove deprecated file /jail/lib/i686
    removing deprecated file /jail/usr/lib/locale/en_US.utf8
    ERROR: failed to remove deprecated file /jail/usr/lib/locale/en_US.utf8
    removing deprecated file /jail/usr/share/vim/vim72
    ERROR: failed to remove deprecated file /jail/usr/share/vim/vim72
    ERROR: while scannign dir /jail/opt/: No such file or directory
    user@server:[18:20]:/etc/jailkit# jk_init -v -f -k -j /jail ssh
    Source file(s) /lib/libnss_dns.so.2 do not exist
    Source file(s) /lib64/libnss_dns.so.2 do not exist
    Creating symlink /jail/lib/x86_64-linux-gnu/libnss_dns.so.2 to libnss_dns-2.19.so
    Trying to link /lib/x86_64-linux-gnu/libnss_dns-2.19.so to /jail/lib/x86_64-linux-gnu/libnss_dns-2.19.so
    Creating symlink /jail/lib/x86_64-linux-gnu/libresolv.so.2 to libresolv-2.19.so
    Trying to link /lib/x86_64-linux-gnu/libresolv-2.19.so to /jail/lib/x86_64-linux-gnu/libresolv-2.19.so
    Creating symlink /jail/lib/x86_64-linux-gnu/libc.so.6 to libc-2.19.so
    Destination file /jail/lib/x86_64-linux-gnu/libc-2.19.so exists, will delete to force update
    Trying to link /lib/x86_64-linux-gnu/libc-2.19.so to /jail/lib/x86_64-linux-gnu/libc-2.19.so
    Create directory /jail/lib64
    Traceback (most recent call last):
    File "/usr/sbin/jk_init", line 244, in <module>
    main()
    File "/usr/sbin/jk_init", line 241, in main
    activateConfig(config, jail, args)
    File "/usr/sbin/jk_init", line 161, in activateConfig
    ji.handle_cfg_section(config,jail,cfg,section)
    File "/usr/sbin/jk_init", line 98, in handle_cfg_section
    self.handle_cfg_section(config,chroot,cfg,tmp)
    File "/usr/sbin/jk_init", line 107, in handle_cfg_section
    self.didfiles = jk_lib.copy_binaries_and_libs(chroot, paths2, config['force'], config['verbose'], 1, try_hardlink=config['hardlink'],try_glob_matching=1,handledfiles=self.didfiles)
    File "/usr/share/jailkit/jk_lib.py", line 695, in copy_binaries_and_libs
    handledfiles = copy_binaries_and_libs(chroot, [realfile], force_overwrite, be_verbose, check_libs, try_hardlink, allow_suid, retain_owner, handledfiles)
    File "/usr/share/jailkit/jk_lib.py", line 714, in copy_binaries_and_libs
    handledfiles = copy_binaries_and_libs(chroot, libs, force_overwrite, be_verbose, 0, try_hardlink, handledfiles=handledfiles)
    File "/usr/share/jailkit/jk_lib.py", line 642, in copy_binaries_and_libs
    create_parent_path(chroot,os.path.dirname(file), be_verbose, copy_permissions=1, allow_suid=allow_suid, copy_ownership=retain_owner)
    File "/usr/share/jailkit/jk_lib.py", line 464, in create_parent_path
    os.mkdir(jailpath, 0755)
    OSError: [Errno 13] Permission denied: '/jail/lib64'
     
  2. Nap

    Nap Member

    My packages are all up to date as of the end of last week.
    (I'm so close to the 10K character limit, I thought I would post this here. I could not prune the OP any more.)
     
  3. Nap

    Nap Member

    Fixed the ssh related problem.
    I found the 'shelluser_jailkit_plugin.inc.php' and 'cron_jailkit_plugin.inc.php' scripts, and the sections listed in the 'servers' table.

    Now back to fixing the problem with the colours and keys.

    Cheers,
    Nap

    The list of Jailkit commands I used to repair are:

    jailkit_chroot_app_sections=
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 basicshell
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 editors
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 extendedshell
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 netutils
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 ssh
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 sftp
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 scp
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 groups <= no item in jk_init.ini for this section
    jk_init -f -k -c /etc/jailkit/jk_init.ini -j /var/www/clients/client1/web2 jk_lsh

    jailkit_chroot_app_programs=
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/groups
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/id
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/dircolors
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/lesspipe
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/basename
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/dirname
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/nano
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/pico

    jailkit_chroot_cron_programs=
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/php
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/perl
    jk_cp -k /var/www/clients/client1/web2 /usr/share/perl
     
  4. Nap

    Nap Member

    For those who are having the Home/End key and Colour Terminal problems, try adding the following to the jailkit setup:
    Code:
    jk_cp -k /var/www/clients/client1/web2 /etc/inputrc
    jk_cp -k /var/www/clients/client1/web2 /lib/x86_64-linux-gnu/libreadline.so.*
    jk_cp -k /var/www/clients/client1/web2 /usr/bin/tput
    
    I also editted the 'config' field of the 'server' table in the ISPConfig database to include these for future use.
     

Share This Page