wiki:doc/TorBOX/Dev/BuildDocumentation/0.3.0

Version 8 (modified by proper, 7 years ago) (diff)

--

aos Homepage

NOT FINISHED!

# Copyright:
# adrelanos (aka proper)
# adrelanos (at) riseup (dot) net
#
# License:
# GPL v3 or any later
#
# Any changes you pull into this source will be also licensed
# under GPL v3 or any later. Additionally you grant adrelanos the right to
# re-license your work under a different license. If that is not acceptable,
# you can either fork this source under GPL v3 or any later or contact
# adrelanos. Contact adrelanos, if you require this source code under
# different license.
#
# Authors:
# adrelanos (aka proper)
# Big contributions from anonymous.
# Leaktest and other stuff contributed by smarm.

This page documents how the binary distribution images are built. If you have any questions or need help let us know on /aos/Dev#Question.

Following these instructions will build version aos 0.3.0 based on Tor 0.2.3 and Ubuntu Precise.

Knowledge assumed: Virtualization and networking basic principles; operation of your platform; Linux knowledge: how to install Ubuntu and basic command line knowledge.

Only one prerequisites: you need a working internet connection.

For discussion related to the development and build process of aos images go aos/Dev/.

Build Anonymity

While downloading the required tools for building aos your internet service provider could if he want notice that you want to build aos. This is esspecially interesting, if you want to redistribute aos, but still want to stay anonymous. The full story can be read in the chapter Build Anonymity.

Build Security

  • Build on a dedicated build system, install security updates...
  • All install media and all downloaded/used code must be verified (including all software on the host).
  • Hashes, fingerprints in the scripts and the wiki is not to be trusted. Verify everything.
  • Read aos/Trust

Host preparation

Read and apply if necessary Network Time Syncing!

We recommend you use a dedicated OS installation just for hosting the aos VMs (See aos/SecurityAndHardening)

You need to use Ubuntu. The build scripts could be adapted to run on other *NIX systems as well but currently they assume apt-get to be available. You need about 15 GB of free space.

Install the latest security updates, install Virtual Box (and qemu-kvm which is required to mount the Virtual Box .vdi images). Reboot to apply kernel updates.

sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install virtualbox qemu genisoimage
sudo reboot

If you are going to use Virtual Box inside Virtual Box, be sure to change your host key. Virtual Box -> Preferences -> Input -> Host Key. The "outside" and the "inside" Host Key must differ, otherwise you can not leave the VM "inside" anymore. The "outside" Virtual Box hostkey may NOT be ctrl.1
1 Because the one is used by VBoxSDL "inside".

Building on Windows is no longer supported. Redistributed aos builds should be build on Linux. If you want to port the aos build scripts to Windows, please contact us. Running aos on a Windows host with Virtual Box installed should is still possible.

Using an apt cache to speed up downloading

OPTIONAL

Does only work with aos-Gateway.
Does not work for aos-Workstation because it never gets direct access to the host by design. We could think about installing apt-cacher-ng on aos-Gateway, if there are any security implications.

If you want to build multiple times (for debugging etc.), it might make sense to install a local apt proxy on your build machine. That safes download time and traffic.
Thanks to source.

On the host:

sudo apt-get install apt-cacher-ng
sudo nano /etc/apt/apt.conf
Acquire::http { Proxy "http://127.0.0.1:3142"; };
sudo apt-get update

In aos_gateway source code:
Go to /home/user/aos/aos_gateway/usr/local/bin/aos_internal_install_script script and comment in the line Acquire::http { Proxy "http://192.168.0.2:3142"; };, i.e. remove the # (hash) in front of it.

Source Code Intro

If you prefer to read and understand the source code just by reading scripts you may skip this optional chapter. This chapter is dedicated to give an introduction into the aos source code. It can be quite difficult to get started with hacking existing big complex projects.

Both Virtual Machines will be started two times while building aos. The first time the operating system will be installed and the second time either the aos_internal_install_script runs.

aos_gateway All files within that folder will be copied into aos-Gateway.
aos_workstation All files within that folder will be copied into aos-Workstation.
aos_shared All files within that folder will be copied into aos-Gateway and aos-Workstation.
Copying is done with aos_craetevm and implemented in int_copy_gateway, int_copy_workstation and int_copy_shared.

int_xxx scripts are internally used by aos_xxx scripts.

aos_build is a script, which simply runs all other scripts. Actually it's "optional". It has very little functionality beside running all other scripts. You are free to run all scripts one by one. That is useful for learning and for debugging purposes. In case you want to fix a bug or in case you want to upgrade the distribution or in case you want to switch the operating system or whatever you are better off running the steps manually. You can use the Build script as a reference for which steps have to be run in which order.

aos_getiso downloads and verifies the operating system iso image.

aos_modifyiso mounts the downloaded iso image as read only, copies it, modifies the copied iso image by adding preseeding (unattended installation), unmounts the iso and finally creates preseed.iso, which contains the operating system installer disc modified not to require any user interaction while installing. This process already sets up lots of important privacy settings and other stuff, such as UTC timezone, hostname ubuntu, US language, username user and so on. (See aos/SecurityAndHardening and the modifyiso script itself for a list of all changes and why.) Preseed.iso is configured to power off itself when it's done installing so the aos_build script can continue.

aos_createvm creates Virtual Box machines with all settings required for secure networking, devices, security settings. Which those settings are in details can be again read in Security And Hardening or the script itself. aos_createvm is also responsible for starting virtual machines while building. It also features to mount the virtual hdd images for debugging reasons. The aos_internal_install_script will be copied into the VMs by aos_createvm.

aos_internal_install_script A aos-Gateway specific version is stored under /home/user/aos/aos_gateway/usr/local/bin/aos_internal_install_script and a aos-Workstation specific version is stored under /home/user/aos/aos_gateway/usr/local/bin/aos_internal_install_script. This script gets copied into the Virtual Machines by aos_createvm. aos_internal_install_script gets automatically started, only once at build time, by rc.local. They will transform the installed operating system into the aos-Gateway or into the aos-Workstation. They update the system, install security relevant software, install useful applications for an anonymous general purpose operating system, set up all relevant privacy and anonymity required settings, desktop manager etc.

rc.local (/home/user/aos/rc.local) gets copied to into the VMs to /etc/rc.local and keeps care of automatically starting aos_internal_install_script. 2 The final version of rc.local, which the user will see, will be reverted by 'aos_createvm -tX-copyinto-post' and can be found under /home/user/aos/aos_shared/etc/rc.local.

Thus, given the nature of the build step orientated scripts, you can easily work on the the different aspects of aos. For example, once you have created a clean virtual machine with the operating system only, you can make a clone or snapshot, run either the aos_Gateway or the aos_Workstation script as often as you need to test your changes and if something goes wrong, go back to the clone or snapshot. You don't have to build everything from scratch again. 3

3 For example, we could add the aos_Gateway or aos_Workstation script to the preseed.iso and let it run after installing. If something would go wrong, you would have to reinstall the whole operating system every time again. That's why we use separate steps.

Get the aos source code

git clone https://github.com/adrelanos/aos

Create the Images

Preparations

Make the build script executable:

chmod +x ~/aos/aos_*

Make sure there aren't any VMs in Virtual Box already called "aos-Gateway" or "aos-Workstation" (TODO: automate that)

VM Creation

-all not supported yet.

  1. Open a shell and type:
    sudo ~/aos/aos_build -tg
    
  1. Check if all went ok.
  1. Power on aos_Gateway
  1. Open a shell and type:
    sudo ~/aos/aos_build -tw
    

The scripts can fail for many reasons, please report back any issues!

How to use the ova images

Reboot both VMs. Please read the aos/Readme!

Final Steps (Only Required For Redistribution)

  • Leak Testing!
  • Test the images before release! TODO: Needs big revision with all aos features.
  • Update the Changelog.
  • Create hash sums for verification.
    sha512sum aos-Gateway.ova
    sha512sum aos-Workstation.ova
    
  • Upload the images.
  • Post hash sums to build documentation.
  • Post download links to build documentation.
  • At least a few testers should test before posting a news. Testers may be found by posting a news.
  • Finally announce: Post a news.