cluster:chroot
Guias para hacer chroot
https://geek.co.il/2010/03/14/how-to-build-a-chroot-jail-environment-for-centos
https://www.tecmint.com/restrict-ssh-user-to-directory-using-chrooted-jail/
Primero crear el sistema,
$ mkdir -p /nas/chroot $ mkdir -p /nas/chroot/var/lib/rpm $ rpm --rebuilddb --root=/nas/chroot $ wget http://mirror.centos.org/centos/6/os/x86_64/Packages/centos-release-6-10.el6.centos.12.3.x86_64.rpm $ rpm -i --root=/nas/chroot --nodeps centos-release-6-10.el6.centos.12.3.x86_64.rpm $ yum --installroot=/nas/chroot install -y rpm-build yum
Ahora el environment,
[root@detritus ~]# ls -l /dev/{null,zero,stdin,stdout,stderr,random,tty} crw-rw-rw- 1 root root 1, 3 Dec 12 18:33 /dev/null crw-rw-rw- 1 root root 1, 8 Dec 12 18:33 /dev/random lrwxrwxrwx 1 root root 15 Dec 12 18:33 /dev/stderr -> /proc/self/fd/2 lrwxrwxrwx 1 root root 15 Dec 12 18:33 /dev/stdin -> /proc/self/fd/0 lrwxrwxrwx 1 root root 15 Dec 12 18:33 /dev/stdout -> /proc/self/fd/1 crw-rw-rw- 1 root tty 5, 0 Feb 21 15:48 /dev/tty crw-rw-rw- 1 root root 1, 5 Dec 12 18:33 /dev/zero [root@detritus ~]# mknod -m 666 null c 1 3 [root@detritus ~]# mknod -m 666 tty c 5 0 [root@detritus ~]# mknod -m 666 zero c 1 5 [root@detritus ~]# mknod -m 666 random c 1 8 [root@detritus ~]# chown root:root /nas/chroot [root@detritus ~]# chmod 0755 /nas/chroot
Añado un usuario,
$ useradd -d /home/anavarro anavarro $ passwd anavarro blah, blah...
copio el usuario dentro del jail,
$ cd /nas/chroot $ grep anavarro /etc/passwd >> etc/passwd $ grep anavarro /etc/group >> etc/group $ cp -r /home/anavarro home/
Edito el archivo /etc/ssh/sshd_config ,
Match User anavarro ChrootDirectory /nas/chroot
y reinicio el sshd,
$ service sshd restart
y ya esta, el pollo dentro de la jaula.
cluster/chroot.txt · Last modified: 2020/08/04 10:58 by 127.0.0.1