The following is a description of how to install Ubuntu & x2go server inside Linux Containers (LXC).
All of the following was done on an Ubuntu 12.04 server installed inside LXC containers. These examples are only for a single container but you can either Clone the first container you create and make necessary changes regarding IP addresses (they will be different for each LXC container) or start from scratch and create each manually.
If you are not familiar with LXC containers it is a very lightweight & therefore very fast (faster than vmware, kvm, xen etc) technology built into most modern Linux kernels and
distributions from Ubuntu, Debian, Fedora etc. Note that LXC does not support installing windows into an LXC container.
LXC allows you to provide complete isolation of one container from another by default.
However, you can as an admin provide more or less isolation between containers and also between containers and the HOST computer OS.
I will NOT go into how LXC works here as there is a lot of information on the web which can help you understand more if you do a google search for "lxc containers" or read some of the "references" I've put at the end of this email.
Ubuntu 12.04 has made LXC very easy to use. Canonical has simplified many things to the extreme. Other linux distributions may/will differ on how you create, access etc LXC containers.
But lets begin creating our first LXC container and then we will install Bonitasoft inside that container.
*STEP 1*
Assuming you are using Ubuntu 12.04 Desktop we will install LXC first the create our first container which we will call x2goserver1-lxc. In the
following we are going to use an “ubuntu” lxc template. There are other “lxc templates” for debian, fedora, centos etc that you could use if
you wanted to install one of those OS inside an LXC Container even if the host is Ubuntu
NOTE: you can install any Linux OS into an LXC container the only major rule is that the Linux must use the same Kernel as the Host linux.
sudo apt-get install lxc*
Next create the LXC container we are calling x2goserver1-lxc then start up that container:
sudo lxc-create -t ubuntu -n x2goserver1-lxc*
sudo lxc-start -n x2goserver1-lxc*
The “create” command above will create a new container called "x2goserver1-lxc" and install ubuntu ... using the same version of Ubuntu as your host computer so it will install ubuntu 12.04 inside the LXC container named "x2goserver1-lxc"
This will take some time as it downloads all the required files from the Ubuntu repositories and installs them to create a bootable Ubuntu 12.04 system.
The “start” command above will actually start the LXC container called "x2goserver1-lxc" and its Ubuntu system and leave you at a terminal command prompt inside the LXC container.
*Note:* that the command prompt will be different from a terminal on your HOST computer as you will now be *inside* the container and because we haven't added any additional user accounts yet the login USERID will be the default which
is "ubuntu".
The command prompt should look something like the following:
*ubuntu@x2goserver1-lxc:~$*
Create a User Accounts for the users that will be using this container:
*sudo adduser user-name1*
etc.*
*STEP 2*
While logged into the container and at the terminal prompt install whatever other tools you usually use.
In my case, because I wanted to see if x2go would work so I installed the ubuntu desktop and the x2go server components.
Install the Ubuntu Desktop:
*sudo apt-get install ubuntu-desktop*
when this completes reboot Ubuntu in the LXC container:
*sudo shutdown -r now*
this will reboot ubuntu in the container so the desktop environment will be available. Login again and continue.
Next install the x2go "server" side applications so I can later access the container using the x2goclient on my HOST PC.
Next add the x2go repository:
sudo add-apt-repository ppa:x2go/stable*
sudo apt-get update*
Install the x2go "server" side components:
sudo apt-get install x2goserver
sudo apt-get install x2goserver-session*
On your HOST computer install the x2go client:
sudo add-apt-repository ppa:x2go/stable
sudo apt-get update
sudo apt-get install x2goclient*
*STEP 3*
This step is important if you want to be able to access the LXC container from the host using SSH or whatever other tools you use.
The genesis of this step is from Stephane Graber who has taught me alot about LXC from his blog.
This step is:
*Add the following to each users ~/.ssh/config file. Note you may have to create ~/.ssh/config if it doesn't yet exist and change the lxc-container IP address to the container that each user is assigned to work with.** * note: each of the following should be a single line entry
Host *.lxc StrictHostKeyChecking no UserKnownHostsFile /dev/null ProxyCommand nc $(host $(echo %h | sed "s/\\\\.lxc//g") * my-lxc-container-ip-address* | tail -1 | awk '{print $NF}') %p
Host *.libvirt StrictHostKeyChecking no UserKnownHostsFile /dev/null ProxyCommand nc $(host $(echo %h | sed "s/\\\\.libvirt//g") * my-host-ip-address* | tail -1 | awk '{print $NF}') %p
From now on you can access the x2goserver1-lxc container using either SSH or the x2go client
*STEP 4*
If you want to use x2go start the x2goclient, then on the HOST create a new x2go "session" and add info about what LXC container IP address you want to connect to, what desktop (unity, gnome etc) and what speed is the connection (change this by moving the slider to LAN since we want the fastest/no compression) and then save.
Start the x2goclient session and log into the LXC container. From now on you can do everything as if you were on your HOST PC.
Just remember you will be inside the LXC container so you are separated from your host and changes made will only be to the LXC container's Ubuntu.
*PARTING THOUGHTS*
The reason for doing all of this? Well there are several I can think of but I’ll just name a couple:
Remember I said that LXC containers can be as isolated from each other and from the HOST as you want. They start totally isolated but we changed that a bit above so you could ssh or x2go into a container by adding the 2 statements to a users ~/.ssh/config file
However, you can allow LXC containers to share a HOST file system/directory, or even a something like an SQL server running on the HOST (again read about LXC CGROUPS).
I may have forgotten a step or mistyped something here and if so send me a note and I'll double check and make any addition/correction.
Have fun...
*References:* http://lxc.teegra.net/ http://www.ibm.com/developerworks/linux/library/l-lxc-containers/ http://www.stgraber.org/category/lxc/
Brian Mullan
Hi Brian,
On Mo 27 Aug 2012 15:59:20 CEST brian mullan wrote:
The following is a description of how to install Ubuntu & x2go server inside Linux Containers (LXC).
Could you put parts of the HowTo into the X2Go wiki? Please do not put
the whole LXC installation procedure into the wiki, rather elaborate
on the SSH/X2Go specific stuff and put that into context of installing
LXC with X2Go.
Please open up a new topic on this page: http://wiki.x2go.org/doku.php/wiki:advanced:start
Thanks, Mike
--
DAS-NETZWERKTEAM mike gabriel, rothenstein 5, 24214 neudorf-bornstein fon: +49 (1520) 1976 148
GnuPG Key ID 0x25771B31 mail: mike.gabriel@das-netzwerkteam.de, http://das-netzwerkteam.de
freeBusy: https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xf...