FreeBSD jail and vnc.

 

 

Create inside one FreeBSD 13 operating system independently running FreeBSD 13 on the same operating system kernel, but completely independently configurable with an independent set of installed applications.

To do this, do the following steps.

 

Add the following line to the /etc/rc.conf file, any way you like, such as this:

 

echo 'jail_enable="YES"' >> /etc/rc.conf

 

ee /etc/rc.conf

jail_enable="YES"

 

mcedit /etc/rc.conf

jail_enable="YES"

 

Create a configuration file

 

 

ee /etc/jail.conf

exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
mount.devfs;
path = "/home/jail/test";
allow.raw_sockets = 1;
allow.sysvipc = 1;

test {
host.hostname = "test";
interface = "re0";
ip4.addr = 192.168.0.105;
}


 

Where re0 is the actual host system interface


 


 

Download and extract the source code for the FreeBSD 13 operating system for Jail


 


 

cd /tmp

 

fetch https://download.freebsd.org/ftp/releases/amd64/13.0-RELEASE/base.txz
fetch https://download.freebsd.org/ftp/releases/amd64/13.0-RELEASE/lib32.txz
tar -xvf base.txz -C /home/jail/test && tar -xvf lib32.txz -C /home/jail/test
rm -rf base.txz && rm -rf lib32.txz

 

 

 

Enabling ssh in jail

 

cd /home/jail/test

echo 'sshd_enable="YES"' > ./etc/rc.conf

 

Let's start jail

 

service jail start

 

Look at the list of jail

 

jls

 

Connect to test

 

jexec test

 

Create a user in jail

 

adduser

 

 

Installing and configuring VNC

 

pkg install tigervnc-server tigervnc-viewer xauth xterm icewm

 

Start with a previously created user in the jail vnc and set a password

 

vncserver :0

 

Kill the process

 

vncserver -kill :0

 

edit the ~/.vnc/xstartup file as follows:

 

 

#twm &

 

export GTK_IM_MODULE=uim

export QT_IM_MODULE=uim

export XMODIFIERS=@im=uim

export XIM=uim

/usr/local/bin/mozc start

uim-xim &

 

exec icewm

 

Launch vnc with the desired resolution

 

 

vncserver :0 -geometry 1980x1080 -depth 24

 

 

 

Uninstalling jail

 

If you want to uninstall the system while in jail, you have to do this

 

chflags -R noschg /home/jail/test

 

rm -R /home/jail/test