July 17, 2019
In an earlier post, we installed Ubuntu 18.04 on a PC that previously ran Windows. In this post, we create a virtual machine which also runs Ubuntu.
Before you can do this, you must assure yourself that your host machine is capable of supporting virtualization. This technology is called Virtual Machine Extensions (vmx) on Intel CPUs and Secure Virtual Machine (svm) on AMD CPUs. Determine whether these CPU flags are present by opening a terminal (Ctrl+Alt+t) and issuing the command:
egrep '(vmx|svm)' /proc/cpuinfo
On some computer models, although virtualization is supported by the CPU, it must also be enabled in the BIOS (UEFI). Instructions for reaching the BIOS vary from manufacturer to manufacturer and from model to model. Generally you must tap a specified key just after rebooting while the machine performs its power-on self-test.
When you are sure that your computer will support KVM, you can install the packages:
To install these packages, issue the command:
sudo apt install qemu-kvm libvirt-bin bridge-utils virt-manager
To allow yourself to manage virtual machines as a non-root user, add yourself to the relevant groups:
sudo usermod -a -G libvirt,libvirt-qemu yourusernamegoeshere
You will need to log out and log in again for the group changes to be effective.
Now download the ISO file for the most recent Long Term Support (LTS) version of Ubuntu Desktop from the Ubuntu website. In the case of a virtual machine, there is no need to burn the ISO file to a USB memory stick. It can remain as an ISO file. It will have a name that resembles ubuntu-18.04.2-desktop-amd64.iso
.
From the Ubuntu applications menu, search for and launch Virtual Machine Manager. Right click on the line for the QEMU/KVM connection. Select Details. Check the Virtual Networks tab for the virbr0
virtual network in state Active, with autostart On Boot. Then close the connection details window.
Now create your new virtual machine.
Downloads
directory, select your Ubuntu ISO file, and click Open.guest
. Click Finish.The Ubuntu installer then launches. Installing Ubuntu on the guest will be very similar to when you installed Ubuntu on the host.
In Virtual Machine Manager, do View then Details. Select IDE CD ROM 1. You should see your Ubuntu ISO. Click Disconnect. Then do Virtual Machine > Shut Down > Force Off.
Press the green start arrow for your virtual machine. The Ubuntu guest machine now boots for the first time.
Once the reboot is done, you are prompted to click on your username and enter the password you chose during installation.
There are some initial What's new in Ubuntu screens to click through the first time you use a new system. When asked if you want to send information to Canonical, select No, and press Next. At the end of the what's new screens, click Done.
Open Ubuntu settings, and go to the Privacy tab.
Open the applications menu and search for Software & Updates.
Now open the terminal emulator (Ctrl+Alt+t) and completely update the system by issuing these commands:
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
Set up the firewall with the commands that follow. All unsolicited input will be blocked. We will, though, allow SSH on port 22 from the host machine.
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -s 192.168.122.0/24 -j ACCEPT
sudo iptables -P INPUT DROP
If your network is IPv6 enabled, also close the IPv6 firewall:
sudo ip6tables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo ip6tables -A INPUT -i lo -j ACCEPT
sudo ip6tables -P INPUT DROP
Persist these changes after reboots:
sudo apt install iptables-persistent
Install and start the SSH server on the guest to allow connections from the host:
sudo apt install openssh-server
Close the terminal emulator window.
We will now harden the security options on Firefox. Open Firefox, click the Firefox hamburger menu, and select Preferences.
To disable WebRTC:
about:config
in the address bar, and press Enter.media.peerconnection.enabled
in the search bar, and press Enter.media.peerconnection.enabled
. The value changes from true to false.You can add further privacy and security extensions to Firefox from the Add-ons menu. Some useful ones to add are: