#!/bin/sh # Creates the kiosk account the whole image is built around. Identical logic to # hosts/thin-client's 0100-user-setup.hook.chroot — see that file's comments for the # reasoning behind the locked password, passwordless sudo, and key-only SSH. set -eu . /etc/touchpanel-agent/config.env if ! id "$KIOSK_USERNAME" >/dev/null 2>&1; then useradd --create-home --shell /bin/bash --comment "Touch panel kiosk session" "$KIOSK_USERNAME" fi for grp in audio video input render dialout netdev plugdev seat _seatd; do if getent group "$grp" >/dev/null 2>&1; then adduser "$KIOSK_USERNAME" "$grp" >/dev/null fi done # No password is baked in: the account is locked so it can never be used to log in # remotely, while the physical console still autologins via greetd. passwd --lock "$KIOSK_USERNAME" >/dev/null adduser "$KIOSK_USERNAME" sudo >/dev/null # Passwordless sudo: this image autologins to an unattended interactive Sway session # at the physical console, so anyone standing in front of the panel already has the # equivalent of a root shell. The boundary that actually matters is key-only SSH below # — there is no wayvnc on this image (see the README for that scope decision). cat > "/etc/sudoers.d/010-${KIOSK_USERNAME}" < /etc/ssh/sshd_config.d/10-touch-panel.conf <<'EOF' PermitRootLogin no PasswordAuthentication no KbdInteractiveAuthentication no PubkeyAuthentication yes EOF if [ -d "/home/${KIOSK_USERNAME}/.ssh" ]; then chmod 700 "/home/${KIOSK_USERNAME}/.ssh" [ -f "/home/${KIOSK_USERNAME}/.ssh/authorized_keys" ] && \ chmod 600 "/home/${KIOSK_USERNAME}/.ssh/authorized_keys" fi chown -R "${KIOSK_USERNAME}:${KIOSK_USERNAME}" "/home/${KIOSK_USERNAME}" systemctl enable ssh >/dev/null 2>&1 || true