virtual box ubuntu 16.04 tutorial

Virtual Box

Disk

Use the VMDK disk format, it’s compatible with other virtualization software

Select dynamic size and split the disk into 2GB chunks

Install

Once the virtual machine has been created start it to select the ubuntu iso

Go through the installation manually

Networking

User NAT

Setup port forwarding for 2222 on host to 22 on guest, assuming OpenSSH was installed the following should now work on the host

ssh -p 2222 USER@localhost

Shared folders

Add the share

Settings > Shared Folders > Machine Folders
# Auto-mount
# Make permanent

sudo reboot now

sudo usermod -a -G vboxsf USER

Create a symlink

cd ~/

ln -s /media/sf_SHARE SHARE

# User might have logout/login first
ls SHARE

Software

LAMP

Apache

Setup port forwarding, using 127.0.0.1 prevents connections not originating on the host

Setting > Network > Advanced > Port Forwarding
# HTTP   127.0.0.1 8080 =>  80
# HTTPS  127.0.0.1 8443 => 443

Test from host, should show default apache page

http://localhost:8080

Also see setting up virtual hosts

MySQL

Ssh to VM then use mysql client to connect

mysql -u root -p

use mysql;

show tables;

select * from user\G

select Host, User from user;

MySQL tutorial

SQL tutorial

PHP

Tests it’s working

echo "<?php print(1+2);" | php

Python

Tests it’s working

echo "print(1+2)" | python

SQLite

Create a database

cd ~

sqlite3 file.db

.databases

create table monkey (id integer primary key, name text not null);

.tables

insert into monkey (name) values ('chris');
insert into monkey (name) values ('pj');

select * from monkey;

.quit

Delete the database

ls -lah file.db

rm file.db

Postgres

TODO…

ELK stack

sudo apt-get install openjdk-8-jdk

wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-5.x.list
sudo apt-get update && sudo apt-get install elasticsearch

# Set max mem available to ES by changing -Xms option, e.g. -Xms512m,
# as a rule of thumb make it half the system mem
sudo vi /etc/elasticsearch/jvm.options

Start ES service

sudo service elasticsearch start

Allow remote connections

sudo vi /etc/elasticsearch/elasticsearch.yml
# network.host: 0.0.0.0
sudo service elasticsearch restart

Port forwarding

Setting > Network > Advanced > Port Forwarding
# Elastic Search 127.0.0.1 9200 => 9200

Make sure firewall is disabled

sudo ufw disable

Confirm ES is running

http://localhost:9200

Kibana

sudo apt-get install kibana
sudo service kibana start

Allow remote connections

sudo vi /etc/kibana/kibana.yml
# server.host: "0.0.0.0"
sudo service kibana restart

Port forwarding

Setting > Network > Advanced > Port Forwarding
# Kibana 127.0.0.1 5601 => 5601

Confirm Kibana is running

http://localhost:5601

Filebeat

TODO...

Logstash

TODO...

X-Pack

cd /usr/share/elasticsearch
sudo bin/elasticsearch-plugin install x-pack

Encrypting communication