BACK TO THE HOMEPAGE

Aug 06, 2021 2 min read

Setting up ChromeOS Virtual Machine

ChromeOS can create multiple virtual machines to run various software. Creating a new virtual machine allows for software to be tested without ruining your existing setup. It is also great for running programs in an isolated fashion. In this blog post learn how to Create a new virtual machine in ChromeOS.

Asus Chromebox 2 CN62 codename: Guado:inline

Introduction

  • Create a virtual machine
  • Create a Ubuntu container
  • Create a user account
  • Setup SSH

Create a virtual machine

  1. In a browser press CTRL+ALT+T to open the Chrome OS developer shell (i.e. chrome-untrusted://crosh)
  2. Create a new VM
vmc start sandbox
  1. Create a new profile A profile enable the default settings to be altered.
lxc profile copy default custom-profile
  1. Update the profile setting
lxc profile set minikube-profile security.nesting true
lxc profile set minikube-profile security.priviledged false

Create a Ubuntu container

LXC supports a number of images in the following section Ubuntu is used. To see a list of available images:

lxc image list images:
  1. Create a new container based on Ubuntu 18.04
lxc launch image:ubuntu/bionic sandboxvm --profile custom-profile
  1. Create a new container based on Ubuntu 18.04
lxc launch image:ubuntu/bionic sandboxvm --profile custom-profile
  1. Check the status of the container
lxc list

Note: This screen shows the state of the container. The IP used to access the machine can be seen here.

  1. Run the new Ubuntu container
lxc exec sandboxvm /bin/bash

Create a user account

  1. Add an account (ie. substitute USERNAME with the account name to be used)
useradd -m [USERNAME]
  1. Set a password for the account
passwd [USERNAME]
  1. Add user to sudo group
usermod -aG sudo [USERNAME]
  1. Note the USERID and GROUPID assigned to the USERNAME
cat /etc/passwd

Setup SSH

If a remote SSH connection is required then this needs to be setup on the local and remote hosts.

  1. On the local host VM, generate an SSH key
ssh-keygen
  1. Display the ssh key generated
cat ~/.ssh/id_rsa.pub
  1. On the remote host set up the SSH user
mkdir -p /home/[USERNAME]/.ssh
chmod 700 /home/[USERNAME]/.ssh
touch /home/[USERNAME]/.ssh/authorized_keys
chmod /home/[USERNAME]/.ssh/authorized_keys
  1. Paste the generated key into the authorized_keys file e.g.
echo "[SSHKEY]" >> /home/[USERNAME]/.ssh/authorized_keys

Connect via SSH

  1. Get the IP of the container via the LXC screen
  2. Connect via SSH
ssh [USERNAME]@[IP]

Connect via LXC

  1. Login as root
lxc exec sandboxvm /bin/bash && cd
  1. Login as a specific user and use their home directory

To connect as a specific user:

  • USERID
  • GROUPID
  • USERNAME
lxc exec sandboxvm --user [USERID] --group [GROUPID] --cwd [USERID] --env HOME=/home/[USERNAME] /bin/bash && cd