Adding another user to Qubes

What do you do when someone asks if they can borrow your computer? How do you let them use it in a safe, controlled way? If you trust them you might start a disposable and pass over the machine. Will you watch what they are doing? All the time? How do you maintain control over your device?

This post outlines a method I use for demonstration purposes. It allows another user to get a taste for Qubes, while restricting their access as far as possible. To do this we use:an interface qube

Create sys-gui

The easiest way to create an interface qube called sys-gui is to run the salt state:

sudo qubesctl top.enable qvm.sys-gui
sudo qubesctl --all state.highstate

This will create a new qube, sys-gui, and create a new login option. If the output indicates success, disable the sys-gui state:

sudo qubesctl top.disable qvm.sys-gui

Create new qubes for the second user

Create a new qube and a disposable template to use in sys-gui. Clone a new template to be used for this purpose. You make sure that qubes can be used in sys-gui by setting guivm, and making sure that the tag created-by-sys-gui is set

qvm-clone  debian-13-xfce template-debian
qvm-create demo     -t template-demo -l purple
qvm-create demo-dvm -t template-demo -l purple
qvm-prefs  demo     guivm dom0
qvm-prefs  demo-dvm guivm dom0
qvm-tags   demo     set created-by-sys-gui
qvm-tags   demo-dvm set created-by-sys-gui
qvm-tags   demo     del created-by-dom0
qvm-tags   demo-dvm del created-by-dom0
qvm-prefs  demo-dvm template_for_dispvms True

Log out of Xfce, select sys-gui at the login screen, and login using your normal username and password. You should see that the Qubes menu contains entries for the qubes you have just created. You may need to open the qube settings to renew the applications in the menus, or run qvm-features demo-dvm set appmenus-dvm 1 to populate the menu for disposables.

Create a new user

The first step is to create a new user account in dom0. Unlike the normal user account, this account should not be able to sudo to root, so we will only assign membership of the qubes group.

sudo adduser demo
sudo passwd demo
sudo usermod -aG qubes demo

Restrict access to consoles

Now we have a demo user, we can restrict access to virtual consoles (by, for example, Ctrl+Shift+F2). We ensure that the policy file at /etc/security/access.conf contains restrictions, by adding these lines

-:ALL EXCEPT wheel shutdown sync:LOCAL
-:demo:LOCAL

To make sure that this policy is implemented check /etc/pam.d/login: it should contain this line in the account section

account required pam_access.so

Insert it if it is not present.

You can test this restriction by accessing a console using Ctrl+Shift+F2: if you try to log in using demo as username, with the password you set, you should see "Permission Denied"; you should be able to log in with our normal login details, and then use exit to logout. Ctrl+F1` will bring you back to the GUI.

Stop the new user from logging in to Xfce in dom0:

This is relatively straightforward. We create a wrapper script around the Xfce launcher which will exit if the username is demo, but otherwise allow log in as normal.

The wrapper is simple. Create a file at /usr/local/sbin/xfce-session-guard with this content:

#!/bin/sh
if [ "$( id -un)" = "demo" ]; then
  echo "Xfce login disabled"
  exit 1
fi
exec "$@"

To use the wrapper, edit /usr/share/xsessions/xfce.desktop, and edit the line at the end of the file, beginning Exec:

#Exec=/usr/sbin/startxfce4
Exec=/usr/local/sbin/xfce-session-guard /usr/bin/startxfce4

Log out of Xfce, and confirm that:

  1. the normal user can log in to dom0 Xfce

  2. the normal user can log in to Xfce in sys-gui

  3. the demo user can not log in to dom0 Xfce

  4. the demo user can log in to Xfce in sys-gui

Comments

At this stage you can log out of your session, and log in to sys-gui using the demo login. Another user will be able to use disposables, and the demo qube you created, without access to your qubes. This provides some measure of compartmentalisation between you and the demo user.

There are some interesting features of this arrangement. If the demo qubes have their netvm set to "normal" sys-firewall, then they can use that networking, but will not be able to control those qubes, or, (for example), see the network manager applet. If the demo qubes have audiovm set to dom0, then they can use audio but will not be able to control output except with in-qube controls.

The second user will be able to move/copy files between qubes in the sys-gui environment, but not to qubes in the normal environment. They can create qubes, but not qubes with the same name as existing qubes, even though they cannot see those qubes in the sys-gui Qube Manager.