sudo apt install debootstrap schroot -y
sudo debootstrap --arch=amd64 bookworm /var/chroot/debian12 https://deb.debian.org/debian
# sudo mount --bind ~/rootme /var/chroot/debian12/home/ # mount workfolder if needed
Mount the chroot and install tools and things (UNSECURE)
sudo chroot /var/chroot/debian12 /bin/bash
Install node and npm in chroot
sudo chroot /var/lib/chroot/debian12 /bin/bash -c \
" apt-get install -y nodejs npm"
Mount the chroot with unshare (SECURE)
#! /bin/bash
# ~/bin/claude-jail.sh
JAIL=/var/chroot/debian12
PROJECT=${1:- ~/ rootme}
EXTRA=${2:- ~/ ai}
mkdir -p " $JAIL /home"
mkdir -p " $JAIL /mnt/extra"
mkdir -p " $JAIL /proc"
mkdir -p " $JAIL /tmp"
sudo mkdir -p " $JAIL /mnt/extra"
suod chown -R root:root $JAIL /
sudo unshare --mount --pid --fork --map-root-user /bin/bash -c "
mount --bind '$PROJECT ' '$JAIL /home' &&
mount --bind '$EXTRA ' '$JAIL /mnt/extra' &&
mount -t proc proc '$JAIL /proc' &&
mount -t tmpfs tmpfs '$JAIL /tmp' &&
chroot '$JAIL ' /bin/bash -c 'cd /home && npx @anthropic-ai/claude-code'
umount '$JAIL /mnt/extra' 2>/dev/null
umount '$JAIL /home' 2>/dev/null
umount '$JAIL /proc' 2>/dev/null
umount '$JAIL /tmp' 2>/dev/null
"
claude-jail.sh ~ /rootme ~ /documents/specs