Debian Linux Vagrant VirtualBox
This is the third and last post of this series.
Please login as root user into the VirtualBox.
Next we will update aptitude package information and upgrade our packages with the two following comamnds
apt-get update
apt-get upgradeWe will install build-essential, module-assistant, zerofree and openssh-server with the following three commands.
apt-get install -y build-essential module-assistant
module-assistant prepare
apt-get install -y sudo zerofree openssh-serverWe need to give the vagrant user some permissions. Please run visudo.
visudoAnd add the following line, maybe after the root user and close the editor after saving the file.
vagrant ALL=(ALL) NOPASSWD: ALLPlease restart the machine with the two following commands.
shutdown -r nowWe want to configure ssh for the vagrant user. Please login as vagrant user and type the following commands.
mkdir -p /home/vagrant/.sshWe now have to create the public key for the vagrant user. Please create the file /home/vagrant/.ssh/authorized_keys with the following content on your machine.
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public keyThis is an insecure public key for the vagrant user. After that we edit the file /etc/ssh/sshd_config with
any editor, for example nano.
sudo nano /etc/ssh/sshd_configAnd uncomment the line.AuthorizedKeysFile %h/.ssh/authorized_keysNow we can restart ssh.
sudo service ssh restartPlease click in the menu of the machine on Device and in the submenu on Insert Guest Additions CD image ....

After that we will mount and run the guest additions with the following three commands.
sudo mount /dev/cdrom /mnt
cd /mnt
sudo ./VBoxLinuxAdditions.runLet's remove some unused stuff.
sudo rm -rf /usr/share/doc
sudo rm -rf /usr/src/linux-headers*
sudo rm -rf /usr/src/linux
sudo find /var/cache -type f -exec rm -rf {} \;
sudo find /usr/share/locale/* -maxdepth 1 -type d ! -name "de*" ! -name "en*" -exec rm -rf {} \;
sudo rm -rf /usr/src/vboxguest*
sudo rm -rf /usr/src/virtualbox-guest*Zerofree finds the unallocated blocks with non-zero value content in an ext2, ext3 or ext4 file-system and fills them with zeroes.
Run the following comamnd to get root.
sudo init 1Let's run zerofree.
mount -o remount,ro /dev/sda1
zerofree /dev/sda1We will now finish the box by shuting down.
shutdown -h nowAnd after that we can create the box with the following command from our host system.
vagrant package --base debian\ jessie