How do I use the terminal SCREEN when chrooted?
Solution 1
SCREEN probably needs devpts, the pseudo-terminal filesystem, to be mounted on /dev/pts
inside the chroot.
mount -t devpts none "$rootpath/dev/pts" -o ptmxmode=0666,newinstance
ln -fs "pts/ptmx" "$rootpath/dev/ptmx"
(The newinstance
flag is optional; it gives the user a completely separate pty list, preventing them from knowing what other users are logged in.)
Solution 2
In out-of-stock Ubuntu-14.04 this also can be achieved with one "mount" and one "chmod".
Here is /mnt/old
is chroot's target directory (new "root").
Also assumed user user
belongs to group of /mnt/old/run
directory (will be a /run
in chroot-ed environment).
sudo mount --bind /dev/pts /mnt/old/dev/pts
sudo chmod g+w /mnt/old/run
sudo chroot --userspec=user:user /mnt/old
screen
Caveats: Not sure if sharing of /dev/pts
is really a good idea from security perspective, and I would not recommend this method if security is of concern.
Related videos on Youtube
Muktadir Miah
Updated on September 18, 2022Comments
-
Muktadir Miah over 1 year
How do I allow a user to use SCREEN on a chrooted user?
I have tried everything but I keep on failing.
I need the user to be able to use SCREEN when they are logged in bash as a chrooted user.
-
xception over 11 yearsThe chrooted user must have enough access to open a new pty, also your question needs more info, do you use any extra security on your system (grsec, selinux, other)?
-
-
Muktadir Miah over 11 yearsDo I do that on the root user?
-
user1686 over 11 years@MuktadirMiah: Yes, and you do that for every user's chroot. (You can automate it with
pam_exec
.) -
Muktadir Miah over 11 years"I ran "mount -t devpts none "/home/jail/dev/pts" -o ptmxmode=0666,newinstance" I get the error "mount: mount point /home/jail/dev/pts does not exist" I used this tutorial to chroot the user: dharmitshah.blogspot.co.uk/2011/12/…
-
user1686 over 11 yearsIf the mountpoint does not exist, create it. With
mkdir
. -
Muktadir Miah over 11 yearsI have done it but still I get "-su: screen: command not found" on the chrooted user.
-
user1686 over 11 yearsThen copy
screen
and its files into the chroot... (Tip: Next time, please mention the error message sooner.) -
Muktadir Miah over 11 yearsI am now getting error "screen: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory"
-
user1686 over 11 yearsThen copy the libraries into the chroot.
-
Muktadir Miah over 11 yearsHow do I do this?
-
user1686 over 11 yearsRun
ldd /usr/bin/screen
, then copy all files listed...