I have a user who is jailed.
Subsystem sftp internal-sftp
Match user matt
This works perfectly for sftp. The user is limited to his home folder, and whatever mounts are there.
But, I'd like to also give this use shell access. This is what happens when they attempt to log in:
$ ssh [email protected]
Via fstab, the bin folder is mounted to the home directory and is present.
Why am I getting this error.. and how can I solve this?
Thanks for the help!
When you chroot, the named directory becomes /. The correct shell path inside the chroot is then /bin/bash, not /home/matt/bin/bash.
You will also need to make sure there's enough other stuff inside the chroot for the system to work. You can test this with sudo chroot /home/matt /bin/bash and see what works and what doesn't; at the very least, you will probably want a dummy /etc, a bind mount of /proc, and much of /lib inside the chroot.
sudo chroot /home/matt /bin/bash
I'm a chroot novice trying to make a simple chroot jail but am banging my head against the same problem time and time again... Any help would be massively appreciated
I've created a directory /usr/chroot that I want to use as a jail and created subdirectories under it and copied the dependencies of /bin/bash into it:
[root@WIG001-001 ~]# cd /usr/chroot/
[root@WIG001-001 chroot]# ls
[root@WIG001-001 chroot]# mkdir bin etc lib var home
[root@WIG001-001 chroot]# ldd /bin/bash
linux-vdso.so.1 => (0x00007fff99dba000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00000037a2000000)
libdl.so.2 => /lib64/libdl.so.2 (0x000000379fc00000)
libc.so.6 => /lib64/libc.so.6 (0x000000379f800000)
[root@WIG001-001 chroot]# cp /lib64/libtinfo.so.5 /usr/chroot/lib/
[root@WIG001-001 chroot]# cp /lib64/libdl.so.2 /udr/csr/chroot/lib/
[root@WIG001-001 chroot]# cp /lib64/libc.so.6 /usr/chroot/lib/
[root@WIG001-001 chroot]# cp /lib64/ld-linux-x86-64.so.2 /usr/chroot/lib/
[root@WIG001-001 chroot]# cp /bin/bash bin
[root@WIG001-001 chroot]# pwd
[root@WIG001-001 chroot]# /usr/sbin/chroot .
/usr/sbin/chroot: cannot run command `/bin/bash': No such file or directory
it looks like the /bin/bash created under /usr/chroot is fine as the below works:
[root@WIG001-001 chroot]# su - nobody -s /usr/chroot/bin/bash
Can anyone give me any idea where to go from here?
The error message is misleading: /bin/bash: No such file or directory can mean either that /bin/bash doesn't exist, or that the dynamic loader used by /bin/bash doesn't exist. (You'll also get this message for a script if the interpreter on the #! line doesn't exist.)
/bin/bash: No such file or directory
/bin/bash is looking for /lib64/ld-linux-x86-64.so.2 but you provided /lib/ld-linux-x86-64.so.2. Make /usr/chroot/lib64 a symbolic to lib or vice versa.
Just do this: mv /usr/chroot/lib /usr/chroot/lib64
mv /usr/chroot/lib /usr/chroot/lib64