This class is intended as a follow-on to the Code Academy command line course.
Flay's draft slides are here.
This class runs on a multiuser VM. The management account on the VM runs a browser-based SSH server so that users can log into the VM without any tools besides a web browser, and a registration application that allows class participants to generate their own SSH accounts.
The browser-based SSH server uses WebSSH.
The registration application is a small Flask webapp. The CSS for the registration application is based on styles from this site.
Accounts for class participants are created in a group called linux_class
to
simplify tracking and management. To create the group, run:
sudo adduser --group linux_class
The SSH and registration applications are written to work with the latest version of Python. Pyenv makes it easy to use your Python version of choice and create independent virtual environments.
Once pyenv
and pyenv-virtualenv
are installed, run:
pyenv install 3.7.2
pyenv virtualenv 3.7.2 class
pyenv activate class
pip install --upgrade pip
cd ~/linux_class
pip install -r requirements.txt
The registration app runs on port 5000. The Web SSH app runs on port 8000.
- Start the Ubuntu server with a bridged network connection so it appears as another computer on the network.
- Log into the mplough account.
- Get the IP address of the machine.
It's not possible to run adduser
as not root, even if it's suid
. So we
have to run the registration app like this:
cd ~/linux_class/registration_app
sudo -s
pyenv activate class
export FLASK_APP=registration_app.py
/home/mplough/.pyenv/shims/flask run --host 0.0.0.0 -p 5000
I don't like this solution as it involves running a flask app as root, but it's expedient and the risk is acceptable given the isolated and snapshotted nature of the VM.
- Navigate to
/home/mplough/linux_class
directory and run:
wssh --port=8000
From /home/mplough/linux_class/survey_app
,
sudo adduser --conf ./adduser.conf --ingroup linux_class [username]
Nuke a user plus their home directory and files like so:
sudo userdel -r user
The adduser.conf
file in the survey_app
folder directs adduser
to create
a user with a home directory populated by the skeleton in the skel
folder in
this folder.
Note that the adduser.conf
file includes an absolute path. I haven't tested
it with relative paths, so you'll either need to change the absolute path to
fit or you can test relative paths.