Chapter 1: Build Your Practice Lab
Prepare workstation and the lab tools
Phase 10: turn workstation into the machine you work from. You check the everyday tools, give student an SSH key that reaches both servers, and install the lab command that starts and grades every exercise in this path. There is no automation software to install.
Everything in this phase happens on workstation as student. Get there with:
lxc exec workstation -- su - studentPhase 10 ยท Prepare workstation and the lab tools (~20 min)
- Check the everyday tools are installed.
- Log in to both servers with an SSH key, as student and as root.
- Install the lab command and confirm the lab is ready.
VM: check the everyday tools
The lab profile installed these on every VM. Check that they are there on workstation:
rpm -q man-db man-pages tree tmux bind-utils lsof nano vim-enhanced
man --version | head -1Every line should show a package version. If one says not installed, follow Repair an existing lab.
VM: bring workstation up to date
sudo dnf -y upgrade # password: studentVM: set up vim and tmux
Four spaces instead of tabs, line numbers and highlighted search, so editing files in the later chapters is comfortable. Each command writes one small file:
printf '%s\n' 'set number' 'set autoindent' 'set tabstop=4' 'set shiftwidth=4' 'set expandtab' 'set hlsearch' > ~/.vimrcprintf '%s\n' 'set -g mouse on' 'set -g history-limit 10000' > ~/.tmux.confVM: reach both servers by name
The lab's DNS knows every machine by its full name, and the search domain lets you use the short name too.
getent hosts servera.lab.example.com # 172.25.250.10 servera.lab.example.com
ping -c2 serverb # short names workVM: an SSH key for student, on both servers
Make a key pair and copy its public half to student on each server. Each server asks for the password student once; after that, logins need no password. Chapter 10 explains how keys work; for now, this is what lets you and the lab tools move between machines quickly.
ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519
for h in servera serverb; do
ssh-copy-id -o StrictHostKeyChecking=accept-new student@$h.lab.example.com
ssh -o StrictHostKeyChecking=accept-new student@$h true # trust the short name too
done
ssh student@servera hostname # servera.lab.example.com, no password askedVM: let the same key log in as root
lab grade checks your work on the servers as root, the way a classroom's own tools do. The servers refuse root logins with a password but accept them with a key, so put the same key in root's authorized_keys. Each server asks for the sudo password, student, once:
for h in servera serverb; do
ssh -t student@$h 'sudo install -d -m 700 /root/.ssh &&
sudo install -m 600 ~/.ssh/authorized_keys /root/.ssh/authorized_keys &&
sudo restorecon -R /root/.ssh'
done
ssh root@servera id # uid=0(root), no password asked
ssh root@serverb hostname # serverb.lab.example.comRunning it again is harmless: it replaces root's key list with the same single key.
VM: install the lab command
In a training classroom, each exercise starts with lab start NAME. That command exists only inside the classroom, so this site provides its own small script with the same syntax. It downloads each exercise's starter files from this site and checks your results on the servers. It is a short shell script; read it first if you like.
mkdir -p ~/.local/bin
curl -fsSL https://kernelpath.dev/lab/lab -o ~/.local/bin/lab
chmod +x ~/.local/bin/lab
lab version # lab 6
lab check # every line PASS| Command | What it does |
|---|---|
lab start NAME | Creates ~/NAME with that exercise's brief and starter files |
lab grade NAME | Read-only checks of your result on the servers, PASS or FAIL for each requirement; --json exports a report |
lab finish NAME | Moves ~/NAME into ~/lab-archive/, so your notes are kept and your home directory is clear. Add --delete to remove it instead |
lab start NAME --force | Starts over in one step: archives the existing folder and creates a fresh one |
lab list | Every exercise on the site |
lab check | Tests that the lab is ready: the servers, key logins and the site |
lab update | Replaces the command with the newest version from this site |
VM: don't create practice files yet
Leave workstation as it is for now. Your first practice folder comes in section 1.8, after the clean snapshot, so the baseline contains the tools but none of your work.